in reply to Re: Shift versus Sanity
in thread Shift versus Sanity
I have to disagree with you on this one, sort of. I use this construct to set defaults to named parameters like this:# Bad sub bar { my $self = shift; my %options = @_; }
To me, this is the best of both worlds. I get an obvious object ($self), I know what my expected named arguments are, their default values, and a brief description of each parameter. Yes, it's slightly more memory intensive, but it's so much more intuitive to me that I'll take the tradeoff anyday.sub bar { my $self = shift; my %options = (opt1=>'foo', # desc for opt1 opt2=>'bar', # desc for opt2 @_); }
As someone else said, I'll take maintainability over a little verboseness & overhead anyday. Being able to figure out what the heck a rarely used option does is invaluable 4 months (or years!) down the road.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: Re: Shift versus Sanity
by Juerd (Abbot) on Apr 24, 2002 at 17:34 UTC |
In Section
Meditations