> On 17 Nov 2017, at 20:09, Fernando Santagata <nando.santag...@gmail.com> > wrote: > I tried to use the code you suggested: > > sub trait_mod:<is>(Attribute:D \attribute, :&proxy!) { > attribute.package.^add_method(attribute.name, my method () { proxy($_) }) > } > > class A { > has $!a is proxy({ $^a * 2 }); > has $!b is proxy({ $^a * 3 }); > } > > my A $a .= new; > $a.a = 21; # <-- No such method 'a' for invocant of type ‘A'
The problem here is that I forgot that the name of the attribute includes the sigil and the twigil. Which you don’t want to be part of the method name. attribute.name.substr(2) fixes this, but then other problems appear… Looking into that now... Liz