There seems to be a lot of negative commentary on function prototypes through the monastery archives. However, I haven't seen anything that looks like a definitive reason to consider them 'wrong', or a 'failed experiment'. Coming from a C++ background, I've used them religiously since I started coding Perl, and have always found them to work exactly as I expect them to (and as documented). Prototyping (along with use strict, of course) has kept me from having much weirder problems to diagnose than mismatched argument lists.
I'll admit that Perl's function prototypes are kind of weird; but obviously, if you took all the weirdness out of Perl, it would be C, and what would be the fun of that?
There seem to be examples of some problems with what I'd consider bizarre argument lists (particularly with function refs). I haven't ventured into doing such things. For 'normal' scalars, arrays, array refs, hash refs, etc. prototypes work just fine.
Another thread of complaints was this node, but for some reason the author thought that declaring a sub as taking one scalar should accept a list anyway. Whatever. perl.com supposedly has an article that explains it all, but the link isn't working.
Could I get an example of where a function prototype is clearly broken so bad that illustrates why they need to be avoided?
/me is expecting to wind up demoted for daring to post a controversial opinion.
|