develooper Front page | perl.perl6.language | Postings from April 2001

Re: Tying & Overloading

From:
Larry Wall
Date:
April 23, 2001 11:52
Subject:
Re: Tying & Overloading
Message ID:
200104231848.LAA02629@kiev.wall.org
Glenn Linderman writes:
: Why not
: 
:    @foo = @( a + b );   # element by element add of @a and @b

I expect that's be written:

    @foo := @a + @b;

where the := says to treat the left side as a prototype, and a bare
array in a prototype is going to put scalar context on the right side,
and a + in scalar context is going to do the right thing with arrays
in scalar context.  It's possible that a bare = could be made to work
too, but it implies copying a list, where := only implies copying
a pointer.

Larry



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About