in reply to Re^7: Scalar context of slice ("list")
in thread Scalar context of slice
doesn't it hold that when the multiple scalars produced by slicing an array is pushed onto the stack, it also becomes a list? And that all but the last element of that stack-held list of scalars are then discarded when in a scalar context?
So whether an op returns a list or not depends on whether it creates a list internally? It doesn't makes sense to describe the result of a function using different terminology based on whether it builds a list internally or not in order to return that result.
For example, say grep built a list on the stack even in scalar context in an old version of Perl. According to what you said, that grep returns a list in scalar context. That means grep returns a list in scalar context in one version of Perl but not in others, despite returning the number of unfiltered elements in both.
Is it such a "bad meme" to say: A slice results in a list. And a list in a scalar context will return the last element of the slice?
Yes, cause it commonly fails. In the aforementioned version of grep, grep results in a list. And a list in scalar context will return... the last element of the grep? No, it didn't.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^9: Scalar context of slice ("list")
by BrowserUk (Patriarch) on Oct 04, 2008 at 10:22 UTC | |
by ikegami (Patriarch) on Oct 04, 2008 at 11:35 UTC |