On Mon May 04 14:07:56 2009, pmichaud wrote: > 21:00 <TimToady> pmichaud: note that for the self ticket, the phrase in > question is a has initializer, which runs in BUILD context, and hence > does have an obvious instance self, so this isn't really about binding > self to the class > 21:04 <pmichaud> TimToady: okay, thanks. > 21:04 <pmichaud> So we definitely can't leave self as being a plain > lexical, unless we're making use of 'lift' somehow. > 21:05 <pmichaud> or otherwise attach the context to self... which we > have to do anyway. I'll have to think about it a bit more. > 21:05 <jnthn> The thing on the RHS of the = is made a closure already; > we just need to make it an anonymous method. > 21:05 <pmichaud> That works for me. > 21:05 <jnthn> (and remember to pass self in too) > 21:06 <pmichaud> well, the closure has to be invoked on the newly built > object, I suspect. > 21:06 <jnthn> yes > 21:07 <pmichaud> okay, I'll update the ticket. > Updated Rakudo to work this way in git 6229131. So now these work:
> class Foo { has $.a = 1; has $.b = 2; has $.c = $.a + $.b;} > say Foo.new.c 3 And: > class Bar { has $.r = rand } > say Bar.new.r for 1..3; 0.470490443377884 0.6400637382559 0.878367274158286 Did some unfudging and additions to S12-attributes/instance.t. Thanks, Jonathan