in reply to Re^2: If you believe in Lists in Scalar Context, Clap your Hands
in thread If you believe in Lists in Scalar Context, Clap your Hands
What I think JavaFan is getting at when he says "lists in scalar context" is a damaging meme is that there is no such thing, and he feels that this conception leads to serious errors of understanding.
See perlop for why there is no such thing:
A named array in scalar context is quite different from what would at first glance appear to be a list in scalar context. You can't get a list like (1,2,3) into being in scalar context, because the compiler knows the context at compile time. It would generate the scalar comma operator there, not the list construction version of the comma. That means it was never a list to start with.
There's a bit more in the 'Comma Operator' section of perlop.
So, when you have
$r = (1, 5, 10)
perl sees something like
$r = 1 return_right_side 5 return_right_side 10;
and
@r = (1, 5, 10)
becomes something like
@r = list_constructor( 1 list_separator 5 list_separator 10 );
TGI says moo
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^4: If you believe in Lists in Scalar Context, Clap your Hands
by gone2015 (Deacon) on Oct 24, 2008 at 12:30 UTC |
In Section
Meditations