Patrick R. Michaud wrote:
There's currently a problem in that

    class Foo { }

doesn't create 'Foo' as a subclass of Object.
Hmmm....that's odd, since I can do:

class Foo { }
if Foo ~~ Object { say "yes" }
yes
if Foo.new() ~~ Object { say "yes" }
yes

I know that it doesn't explicitly do that in the class declaration method, but in make_proto it will:

   $P0 = get_class 'Perl6Object'
   class.'add_parent'($P0)

If it doesn't have that as a parent already. So from what I can see, it is Foo will end up inheriting from Object. What have you found that doesn't work as it should?

Also, something that might help with the discussion of multimethod
dispatch in rock-paper-scissors is to note that the mmd types do
not have to be directly related in the type hierarchy.  In other
words, we _should_ be able to do the example without needing the
base Thing class. (Whether this currently works or not in Parrot is perhaps another issue. :-)
Appears to work.

class Foo { }; class Bar { }
multi sub test(Foo $x) { say "foo" }
multi sub test(Bar $x) { say "bar" }
test(Foo.new())
foo
test(Bar.new())
bar

So yes, you could re-write it and just write "Object", or "Any" or probably just no type at all (which should default to Any).

Jonathan

Reply via email to