On Mon, 2002-04-08 at 14:37, Randal L. Schwartz wrote:
> >>>>> "Chas" == Chas Owens <[EMAIL PROTECTED]> writes:
> 
> >> There is no meaning for "list in a scalar context", so your statement
> >> makes no sense.
> 
> Chas> my $some_scalar = () = /\s/g;
> 
> Chas> I emphasize again, that is how I _read_ it.  I know that there is no
> Chas> array() and I know why, but that doesn't change how I read things.  This
> Chas> hack forces the far left hand bit to return as a list (by making
> Chas> wantarray return true) which then gets evaluated in scalar context,
> 
> No, that's what I'm saying CANNOT EXIST.

Yes, you are right, that was a slip of the keyboard, I meant that to say
array instead of list.  But I must ask if you are being purposefully
obtuse.  The list assignment operator forces wantarray to to return true
which is what most people would want a mythical array() function for in
the first place, hence my -- again I stress -- _reading_ of () as
array().  I am not claiming that it _is_ array(), but that I find it
helpful to _think of it as_ array() in this context.   

> 
> You cannot have a list in a scalar context.
> 
> You have an array name, or a comma operator, or a list assignment
> operator, or grep, or a slice, or ... , in a scalar context.  But
> NONE OF THOSE GENERATE A LIST IN A SCALAR CONTEXT.
> 
> Chas>  that
> Chas> is what I would want array() for so I simply read () (when used as
> Chas> above) as array(). 
> 
> What you are doing here by adding the () is replacing the right side
> of a scalar assignment with a list assignment instead of the bare
> operator.
> 
> It is this *list assignment* operator when evaluated in a scalar
> context that returns a single value... defined as the number of
> elements present on the right.  But if "list assignment operator in a
> scalar context" had been defined by Larry to be "return last value",
> like a slice, you'd be hosed.  Of course, that'd break the idiom
> 
>         while (($k, $v) = each %foo) { ... }
> 
> for the first false $v, but it'd still mostly work. :)
> 
> THERE IS NEVER A LIST IN A SCALAR CONTEXT.
> 
> Get it?
> 
> -- 
> Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
> <[EMAIL PROTECTED]> <URL:http://www.stonehenge.com/merlyn/>
> Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
> See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
-- 
Today is Pungenday the 25th day of Discord in the YOLD 3168
You are what you see.

Missile Address: 33:48:3.521N  84:23:34.786W


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to