> From: Jonathan Scott Duff
> >   $b = 7, 6, 5
> >   @b = 7, 6, 5
> > 
> > Again, both create identical objects, under different
> > interfaces. But now we have a problem with +$b: what should
> > this mean? To be consistant with +$a (above), I would
> > suggest that it simply returns the sum of its elements
> > (i.e. +(1,2,3) == 6).
> 
> Makes no sense to me.
> 
> if $b and @b are identical objects then what kind of objects are they?
> Are the commas list constructors?  If so, then why wouldn't +$b == 3?
> 
>       $a = 10; $b = 7,6,5;
>       $c = $a + $b;           # what happens here?  Is $c == 28?
> 
> Anyway, this is most bizarre.  My little perl 5 brain can't intuit.


$a and @a are not objects, they are variables. Variables provide
access to objects. $a and @a are different kinds of variables:
when you view an object though a $ variable, it DWIMs like a
scalar; when you view it through an @ variable, it DWIMs like
a list. In numeric context, a $ variable obtains its value via
a .NUMBER method. In the same context, an @ variable uses
the .LENGTH method

In both caes, the underlying object would have both .NUMBER and
..LENGTH methods. The only difference would be that the sigil
defines different mappings between the calling context, and the
method that returns the value.

And thinking about your example, above, the value of $a + $b
is probably 10; for the same reason as 3+"foo" is 3. If you're
using -w then, of course, you also get the warning that
"argument [7,6,5] is not numeric in add at ...".


As others have said, we need Larry to look at all the various
issues and proposals ... and then to chop the baby in half.


Dave.

Reply via email to