I came up with what I think is another valid reason for using function prototypes even though I generally agree they should not be used.
And, of all places, I am suggesting using them on methods. Yes methods, where prototypes are known not to work.
So why you ask?
To prevent people from calling your methods as functions.
For example, the docs for UNIVERSAL::isa say not to call it as a function. But people do it all the time.
if they had declared it like this:
sub isa() { ... }
then they could have prevented this widespread misuse of the API.
Has anyone seen this mentioned anywhere else?
I don't think PBP or Modern Perl mention this.
Thanks!
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.