Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

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

by BrowserUk (Pope)
on Oct 24, 2008 at 20:14 UTC ( #719428=note: print w/ replies, xml ) Need Help??


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

Now try and replace all the information conveyed by the use of the word 'list' in the following sentence from perlsub, with the one or two dozen diagrams like the above, it would take to replace that one word.

If you return one or more aggregates (arrays and hashes), these will be flattened together into one large indistinguishable list.

The only purpose served by the "there's no such thing as a list in a scalar context" meme, is the promotion of one person's intimate knowledge of perl's internals over another's lack thereof; or lack of interest in same.


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.


Comment on Re^10: If you believe in Lists in Scalar Context, Clap your Hands
Re^11: If you believe in Lists in Scalar Context, Clap your Hands
by ikegami (Pope) on Oct 24, 2008 at 20:24 UTC

    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".

      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.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://719428]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (6)
As of 2014-09-21 22:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (176 votes), past polls