Larry,

Thanks much, this all makes sense. :)

Thanks,

Stevan

On Jul 14, 2005, at 4:54 PM, Larry Wall wrote:

On Thu, Jul 14, 2005 at 04:31:07PM -0400, Stevan Little wrote:
: Now, the metamodel currently does not have MMD, and  I think "next
: METHOD" is not as relevant in SMD. So would it make sense to do:
:
:       next SUPER if $?SELF != $?CLASS;
:
: or something like that?

It comes out to that under single inheritance, but under MI it might
well be that the next method that ought to be called is actually a
sibling method.

This is just to clarify for me (and anyone else paying attention), because this made more sense when I "saw" it.

class Foo {
        method baz { ... }
}

class Bar {
        submethod baz { ... }
}

class FooBar is Foo is Bar {}

my $foo_bar = FooBar.new();
$foo_bar.baz() # calls Foo::baz()

No need to respond unless I got it wrong :)


: Here is some example code which might encounter this:
:
: class Foo {
:       method baz { ... }
: }     
:
: class Bar is Foo {
:       submethod baz { ... }
: }
:
: class FooBar is Bar {}
:
: my $foo_bar = FooBar.new();
: $foo_bar.baz() # calls Foo::baz()
:
: basically the dispatch goes from Bar::baz, which says "next SUPER" and
: the dispatcher then goes to Foo::baz since it is a method.
:
: Is that correct?

It says "next METHOD", which has the same effect under SI. But we don't
know whether we're under MI, and we don't know if the dispatcher we're
working under has some weird order of visitation, so it's clearer to
say "next METHOD" and leave it up to the dispatcher to decide if the
SUPER is the next method.  It *usually* is, but...

: You refer to CREATE and BUILDALL as methods here, but A12 calls them
: submethods. Which is correct?

The default versions are methods so that they can be inherited.  The
individual versions defined by classes are submethods unless they intend to be inherited, and force all their subclasses into a new set of default sematics. And they're always called as methods (except when things like
.* cheat).

: >I believe there's pseudo-code for that in A12. The trick is that you : >can always force a call to a submethod of the "wrong" class by taking
: >it as a sub reference and calling it like an ordinary subroutine.
:
: Okay, this is just as dirty a trick as sneaking up into the metamodel, : so I will leave it that way for now, knowing I need to change it later
: :)

Of course, the metamodel can do whatever dirty tricks it likes,
but in Perl 6 the metamodel might actually implement this particular
operation by forcing a sub call through a reference, if the metamodel
is implemented in Perl 6.  It's the only way we've defined to
defeat the .foo dispatcher so far, from a language point of view.
(Though simply calling .meta could also be construed as cheating,
I guess.  Or at least an authorization of cheating on your behalf.)

Larry


Reply via email to