in reply to Re^2: Module Announcement: Perl-Critic-1.01
in thread Module Announcement: Perl-Critic-1.01
You are correct. I can't argue that that is what happens when you return undef.
Now - the larger question is, who is still designing Perl module interfaces that return non-scalar results.
I can't remember the last time I designed a function to return a list of values - much less variably return a list or a single scalar depending upon context. To me it is a code smell to not return a single scalar value (the single value could be arrayref or hashref - but it is still a single value). I know that may not sound Perlish - but as a user of the modules I produce I prefer not have to guess what context I need to call items in. It also saves memory to return arrayrefs or hashrefs.
Yes I still use map and grep and caller and times and stat, but they are some of the last things I use that return lists. Perl 6 will fix some of these issues.
Now - the larger question is, who is still designing Perl module interfaces that return non-scalar results.
I can't remember the last time I designed a function to return a list of values - much less variably return a list or a single scalar depending upon context. To me it is a code smell to not return a single scalar value (the single value could be arrayref or hashref - but it is still a single value). I know that may not sound Perlish - but as a user of the modules I produce I prefer not have to guess what context I need to call items in. It also saves memory to return arrayrefs or hashrefs.
Yes I still use map and grep and caller and times and stat, but they are some of the last things I use that return lists. Perl 6 will fix some of these issues.
my @a=qw(random brilliant braindead); print $a[rand(@a)];
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^4: Module Announcement: Perl-Critic-1.01
by Jenda (Abbot) on Jan 27, 2007 at 00:52 UTC | |
by Rhandom (Curate) on Jan 29, 2007 at 19:07 UTC | |
by Jenda (Abbot) on Jan 29, 2007 at 22:43 UTC |
In Section
Meditations