Problems? Is your data what you think it is? | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
I believe the difference is ambiguity. The procedural function is known and its signature can be examined and used. Depending on what you put in the signature, a %hash might be flattened into an @array, or converted into a \%hashref as it is shoved into @_. With a method call, you cannot be sure how a method call resolve until runtime, and by then it is too late to know what to do with the arguments. In Perl Best Practices, Damien recommends never using signatures. This is both because they are not available in all situations, and because they are easy to mess up. They are not worth the risk of potential problems. Personally, I like 'em. I don't use them for any OO work (obviously), but I do use them for procedural helper routines. This is because if I add or remove an argument and do not update it everywhere, I prefer to get the warning at compile time instead of something at runtime. - doug PS: Improved signatures is one of the perl6 things that I hope hurry up and get here. In reply to Re^3: What's the better Perl style? Define parameters or not?
by doug
|
|