No such thing as a small change | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
I haven't yet some across a case where I've felt a special desire to pass more arguments to the function than the function will use.
Funny. There a number of situations where ive taken advantage of this very feature. And frankly would have been annoyed if the code warned when I did so. An example might be a situation where we extract the contents of a line via a regex, and then process that line via a dispatch function: or something like it. Another example would be overriding a method in a class that takes a certain number of parameters with one that takes a few more. When calling the overriden sub its fairly natural say something like So IMO warning when someone passes too many parameters seems a little extreme. If you do that then I at least hope that you so that I can turn off the annoying messages instead of having to write tortured code just so your sub gets the correct number of parameters. I have come across a similar annoyance when people use prototypes (usually for the wrong reasons, such as argument count checking). I'm especially paranoid against other programmers, Im sympathetic to this postion, but I think its a fine line between being paranoid, and being unduely restrictive. If the end user wants to give you more arguments then you need, then theres a decent chance that decision was a sound one. At a certain point you have to let the end user take responsibility for their own code, and thus their own (mis)use of your code. I certainly disagree with code that makes it impossible to do something just because the author couldnt see any reason why anyone would want to do it. (A position that you arent necessarily advocating I realize, but you can see the relevance I hope.) A good example is code like this: Cheers,
--- demerphq In reply to Re: Re: Context aware functions - best practices?
by demerphq
|
|