in reply to What should be returned in scalar context?
As you can see, I am hardly consistent.So? Perl isn't consistent in this aspect either, and I think, rightly so. What to do in scalar vs list context is something you should decide on a case by case basis, IMO. So, my answer to
Therefore I am interested in which of the above (or other variations of your choice) people think is a good default behaviour to standardize on..and more importantly why.is that I think standardizing is the wrong thing to do.
Why the test on the number of arguments, and the recursion? Wouldn't the following be equivalent?:# And for something completely different... sub foo { if (1 != @_) { return map $foo($_), @_; } # body of foo here. return $whatever; }
sub foo { map { # body of foo here. $whatever } @_ }
Abigail
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: What should be returned in scalar context?
by tilly (Archbishop) on Dec 02, 2003 at 15:22 UTC | |
by Abigail-II (Bishop) on Dec 02, 2003 at 15:39 UTC | |
by ysth (Canon) on Dec 03, 2003 at 18:44 UTC | |
by tilly (Archbishop) on Dec 03, 2003 at 20:14 UTC | |
by BrowserUk (Patriarch) on Dec 03, 2003 at 21:57 UTC | |
by tye (Sage) on Dec 04, 2003 at 06:36 UTC | |
by BrowserUk (Patriarch) on Dec 04, 2003 at 09:27 UTC |