Илья (>): > no one answered at #perl6, so I sending this question in list: > > ihrd: I have question about attr initialization > ihrd: if I have two attr with same name > ihrd: like @.args and %.args > ihrd: and instance object, like .new(args => {foo => 1}), rakudo init both > attr > ihrd: and question is, how this is should work in perl6? > ihrd: rakudo: class B { has $.a; has %.a; has @.a; method foo { say > $!a; say %!a; say @!a; } }; B.new(a => {foo => 1}).foo; > p6eval: rakudo ec55f1: OUTPUT«foo 1foo 1foo 1»
I seem to recall that it was illegal to declare two public attributes with the same name, even when their sigils differ. The reason being that the second public accessor would have to override the first, which doesn't feel right. I haven't checked the spec for confirmation on this; in fact, I think this was mentioned on p6l some years ago. // Carl