in reply to Re^10: If you believe in Lists in Scalar Context, Clap your Hands
in thread If you believe in Lists in Scalar Context, Clap your Hands

The quote is true. Of course, the only way to return more than one aggregate is to be in list context.

If a flattened list was being returned in the following code, it would print "d" instead of "4".

perl -le"print scalar sub { my @a = qw(a b c d); return (@a,@a) }->(); +"

The only purpose served by the "there's no such thing as a list in a scalar context" meme

So? I'm against it too. Too many definitions of list involved. I've been promoting "an operator/function/sub/expression can't return a list in scalar context".

Replies are listed 'Best First'.
Re^12: If you believe in Lists in Scalar Context, Clap your Hands
by BrowserUk (Patriarch) on Oct 24, 2008 at 20:45 UTC
    The quote is true. Of course, ... If ... it would ... sub ...

    Believe it or not, I don't need you to explain these things. I know what happens, but that is a side issue to the point the OP was making in his meditation. As it was in thread that preceded it.

    It's not about what actually happens, it about simple terminology for describing (or analogising) what appears to happen.

    I've been promoting "an operator/function/sub/expression can't return a list in scalar context".

    But that is no replacement for the phrase "a list in scalar context". It's a statement about what doesn't happen, not about what does.


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

      Believe it or not, I don't need you to explain these things.

      I was asked to. "Now try and replace all the information conveyed". The presumption was that I believe there was a need to do so. I don't, so I explained what I believe.

      It's a statement about what doesn't happen, not about what does.

      One doesn't speak about what doesn't happen for its own sake. It's done to explain what does happen or what should happen.

      In this case, we have a misleading statement used to explain what happens when expressions are placed in scalar context. Therefore, that's what the replacement needs to explain.