On Fri, Dec 06, 2002 at 10:40:18AM -0500, Dan Sugalski wrote:
: If an aggregate and a reference to an aggregate are going to behave 
: the same, which is what Larry's indicated in the past, then 
: stringifying a reference should be the same as stringifying its 
: referent.

This is a bit of an oversimplification.  $foo and @foo do not always
behave the same, even if $foo and @foo refer to the same array object.
In particular, $foo doesn't behave like @foo in a list context.
Scalars must continue to behave like scalars in list context, even
if they're internally composite.  As in Perl 5, if you say

    for $foo {...}

the sub only gets one argument, the array ref, but if you say

    for @foo {...}

or

    for @$foo {...}

you get all of the elements.

But it's probably fair to say that $foo and @foo always behave
identically in a scalar context.

We may, in fact, have to deprecate the term "list context" and replace
it with something like "flattening context", since we can have lists
of scalars that are in some sense in a "list context" but that aren't
in a flattening context:

    my ($a,@b,%c) := (@a,$b,%c);

But "flattening" is a lousy word.  It's really more of a "variadic"
context, but that's no improvement.

At the moment I can't think of anything better than "splat" context...

Larry

Reply via email to