Closed doy closed 10 years ago
I guess the main thing here would be figuring out what to do with constructor parameters if there was no conflict.
Then again, we already have this issue with inheritance - there is currently no conflict for class Foo { has $!foo } class Bar extends Foo { has $!foo }
. Is that a problem?
Maybe what we need is to have a way to specify init_arg
s for attributes, and then only conflict on methods and init_args
, not attributes themselves.
hmm, not sure I like that much
$ perl6 -e'role A { has $!foo; method a { $!foo } }; role B { has $!foo; method b { $!foo } }; class C does A does B { }; my $c = C.new; say $c.a; say $c.b'
===SORRY!===
Attribute '$!foo' conflicts in role composition
So, I guess just leaving it as it is would be fine too. I'm not really sure I like that, since it breaks encapsulation a bit (private attributes really shouldn't be visible as part of the public API like that), but I can't really think of a better solution that doesn't end up even uglier.
Now that attributes are class-private, does it make sense for them to still conflict during role application?