|Just another Perl shrine|
Good use for prototypes. On methods no less!by polymorpheus (Novice)
|on Jun 01, 2012 at 19:23 UTC||Need Help??|
polymorpheus has asked for the
wisdom of the Perl Monks concerning the following question:
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:
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!