in reply to Re: What should be returned in scalar context?
in thread What should be returned in scalar context?
I have used that style in functions which transform elements where you might reasonably want to transform one or many elements. The hidden assumption is that it only makes sense to impose scalar context when you are transforming a single element, so behaving badly if you try to transform multiple elements in scalar context is OK.
As for why I would like to standardize somewhat, like I said before, it is all about setting expectations. The trouble with doing something different in each case is underscored by the fact that a top-notch Perl programmer like yourself could be tripped up by what a built-in function does in scalar context. (And to be honest upon seeing you claim that the two should be the same, I actually ran a test program before I was confident in claiming that map had the behaviour that I was specifically trying to work around.)
Besides which, I think that it is overkill to have to give an issue like this serious consideration with every function that I write. Having a default that just flows from my fingers would smooth out the development process.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: What should be returned in scalar context?
by Abigail-II (Bishop) on Dec 02, 2003 at 15:39 UTC | |
|
Re: Re: Re: What should be returned in scalar context?
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 |