Re: confusing list assignment tests

2009-07-28 Thread Larry Wall
On Tue, Jul 28, 2009 at 10:42:01PM +0200, Moritz Lenz wrote: : I guess when I initialize @a[0] = [] it's the same, because then @a[0] : is still a scalar, right? No, as in Perl 5 [] still produces a scalar object that hides the arrayness from list context, so it's like: $b = []; @a[0] = $

Re: confusing list assignment tests

2009-07-28 Thread Jon Lang
Damian Conway wrote: > Mark J. Reed wrote: >> My understanding is that the P6 way to do that is to return a Capture >> containing the desired return values (which can lazily do things only >> when accessed) in the appropriate slots. > > Return a Capture or a more heavily overloaded object, dependin

Re: confusing list assignment tests

2009-07-28 Thread Larry Wall
On Tue, Jul 28, 2009 at 01:22:28PM -0700, Jon Lang wrote: : Larry Wall wrote: : > Moritz Lenz wrote: : > : Either it's parsed as '@a[0] = (W, W)' (list assignment), then @a should : > : get both elements, and so should @z. : > : > Not according to S03, at least by one reading. �...@a[0] as a scalar

Re: confusing list assignment tests

2009-07-28 Thread Damian Conway
Mark J. Reed wrote: > My understanding is that the P6 way to do that is to return a Capture > containing the desired return values (which can lazily do things only > when accessed) in the appropriate slots. Return a Capture or a more heavily overloaded object, depending on how fine a degree of co

Re: confusing list assignment tests

2009-07-28 Thread Moritz Lenz
Jon Lang wrote: > Larry Wall wrote: >> Moritz Lenz wrote: >> : Either it's parsed as '@a[0] = (W, W)' (list assignment), then @a should >> : get both elements, and so should @z. >> >> Not according to S03, at least by one reading. @a[0] as a scalar >> container only wants one item, so it only take

Re: confusing list assignment tests

2009-07-28 Thread Mark J. Reed
My understanding is that the P6 way to do that is to return a Capture containing the desired return values (which can lazily do things only when accessed) in the appropriate slots. On 7/28/09, Jon Lang wrote: > Larry Wall wrote: >> Moritz Lenz wrote: >> : Either it's parsed as '@a[0] = (W, W)' (l

Re: confusing list assignment tests

2009-07-28 Thread Moritz Lenz
Thanks for the quick reply. Larry Wall wrote: > On Tue, Jul 28, 2009 at 09:24:40PM +0200, Moritz Lenz wrote: > : sub W () { substr(eval('want'), 0, 1) } > : ... > : > : # line 560: > : { > : my @a; > : my @z = (@a[0] = W, W); > : #?rakudo 2 todo 'want function' > : is(@a, 'L',

Re: confusing list assignment tests

2009-07-28 Thread Jon Lang
Larry Wall wrote: > Moritz Lenz wrote: > : Either it's parsed as '@a[0] = (W, W)' (list assignment), then @a should > : get both elements, and so should @z. > > Not according to S03, at least by one reading. �...@a[0] as a scalar > container only wants one item, so it only takes the first item off

Re: confusing list assignment tests

2009-07-28 Thread Larry Wall
On Tue, Jul 28, 2009 at 09:24:40PM +0200, Moritz Lenz wrote: : sub W () { substr(eval('want'), 0, 1) } : ... : : # line 560: : { : my @a; : my @z = (@a[0] = W, W); : #?rakudo 2 todo 'want function' : is(@a, 'L','lhs treats @a[0] as list'); : is(@z[0], 'L', 'lhs treats @a[0]