On Tue, Mar 17, 2009 at 05:59:52PM +0100, Jonathan Worthington wrote: > Nicholas Clark wrote: > >Do you have list assignment working properly? ie: > > > > state (@foo) = @bar; > > > >and, I think, > > > > state (@foo) = baz(); > > > > > Aye, thankfully that just fell naturally out of Rakudo's existing list > assignment implementation, though it was under-tested. So I just added:
That feels good. That feels like a clean design. > my @bar = 1,2,3; > sub swatest { > state (@foo) = @bar; > my $x = @foo.perl; > @foo[0]++; > return $x > } > is swatest(), '[1, 2, 3]', 'array state initialized correctly'; > is swatest(), '[2, 2, 3]', 'array state retained between calls'; > Which all pass. Yay. Yay. As does this? my @bar = 1,2,3; sub swatest { (state @foo) = @bar; my $x = @foo.perl; @foo[0]++; return $x } is swatest(), '[1, 2, 3]', 'array state initialized correctly'; is swatest(), '[1, 2, 3]', 'array state retained between calls'; [which IIRC is specified as being different] Nicholas Clark