Ingo Blechschmidt wrote:
Hi,
so we had junctions of Code references some days ago, what's with
junctions of Class and Role objects? :)
I like them! In the type lattice A|B is the lub (lowest upper bound)
of A and B. And A&B is the glb (greatest lower bound) of A and B.
Both are cases of multiple inheritance with possible conflicts. But
A|B is more general than each of A and B, while A&B is more specific
than both.
role A { method foo() { 42 } }
role B { method foo() { 23 } }
class Test does A|B {}
Here you have to implement &Test::foo.
Not doing so is a compile time error---or more
precisly a class composition time error.
my Test $test .= new;
my $ret = $test.foo; # 42|23?
Whatever &Test::foo returns.
role A {}
role B { method foo() { 42 } }
class Test does A|B {}
Here is no conflict, but it might be necessary to
implement the more general behaviour.
my Test $test .= new;
my $ret = $test.foo; # unthrown-exception undef|42?
No, $ret == 42 unless Test::foo() is implemented and returns
something else.
Regards,
--
TSa (Thomas Sandlaß)