develooper Front page | perl.perl6.language | Postings from July 2005

Submethods

Thread Next
From:
Stevan Little
Date:
July 5, 2005 19:15
Subject:
Submethods
Message ID:
66d75282ce3a5782978a83bf59b2bd15@iinteractive.com
Again with the metamodel stuff :P

So, I am trying to implement the submethods correctly, and some 
questions occurred to me.

The concept of non-inherited infrastructural methods is fairly simple 
to accomplish in the meta-model, by just giving submethods their own 
dispatch table inside the metaclass. However where I am somewhat 
confused is in how and when they get called.

Take this example for instance:

class Foo {
	method bar () { ... }
	submethod bar () { ... }
}

Is this an error (Synopsis 12 seems to indicate it is *not* an error)?

When I call bar() on an instance of Foo, which is called? The method? 
or the submethod? Is it somehow dependent upon the calling context? 
(called from within the class, or from outside the class). Take for 
instance, this example:

class Foo {
	method bar () { ... }
	submethod bar () { ... }

	method baz ($self:) {
		$self.bar() # which one does this call?
	}
}

Or are both called? if so, in what order? On method resolution, should 
I first check the submethod table? or the method table (and on up the 
superclass chain)?

Thanks,

Stevan


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About