There's more than one way to do things | |
PerlMonks |
Re: Shift versus Sanityby demerphq (Chancellor) |
on Apr 24, 2002 at 11:02 UTC ( [id://161566]=note: print w/replies, xml ) | Need Help?? |
Interesting post, ++ to you. I found it particularly relevant as I have been working on a post/request for comments (coming soon to Meditations :-) on a class/object technique that I have started using a lot
Although speed was and is definately not my motivation, more the elgance of the notation. Although I am pleased to hear that it is in fact more efficient. :-) Other than that in general I agree with tye pretty much on this one. I often use shift as it is easier to reorganize during development, easier to document and much easier to provide defaults for. Of late I've found myself using $_[$x] a lot as well, primarily as I have been working on a few things where either of the other two techniques can cause problems as they copy their values and not alias to them. Oh yes, when I first started learning perl I reviewed a bunch of the standard modules and corresponded with GSAR about why he (more or less) exclusively used the my $x=shift; idiom (at least in Data::Dumper). Turned out there is/was a bug in an older version of perl that the shift technique worked around.
Yves / DeMerphq
In Section
Meditations
|
|