David Storrs wrote:
Let's move this away from simple types like Str and Int for a moment.

If you consider them simple...

Tell me what this does:

class Tree { method bark() { die "Cannot instantiate a Tree--it is abstract!" }
class Birch { method bark() { return "White, papery" }
class Oak { method bark() { return "Dark, heavy" }
class Dog {
method bark() { print "Woof, woof!"; return "bow wow" }

Four 'pure' classes so far.

class AlienBeastie isa Tree isa Dog {}

Here you get an error/warning of a composition time conflict between &Tree::bark and &Dog::bark. BTW, it's 'is' not 'isa'. My preferred syntax for multiple inheritance is the junctive notation 'is Tree & Dog' for subclassing because it nicely allows for superclassing with 'is Tree | Dog'.

class WhiteAlienBeastie isa Birch isa Dog {}

Same for &Birch::bark and &Dog::bark.

class HeavyAlienBeastie isa Oak isa Dog {}


sub Foo(Tree|Dog $x) { $x.bark() }

This might dispatch correctly for 'pure' Trees, Dogs etc. but not for your mixed classes above.

Regards, -- TSa (Thomas Sandla▀)

Reply via email to