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

Method Resolution Order question

Thread Next
From:
Stevan Little
Date:
July 13, 2005 09:52
Subject:
Method Resolution Order question
Message ID:
169642f884e84d1d2a4164c019e19fb9@iinteractive.com
Hello,

More questions for the metamodel. I am trying to add proper submethod 
and private method handling and I have a question about method 
resolution order as a whole. I asked a similar question last week, but 
this time I have more details :)

Given this class:

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

and given this code:

Foo.new().bar()

What should happen?

The Syn/Apoc seem to indicate that methods and submethods of the same 
name can coexist. So the class definition itself is legal. However, it 
brings up an issue when it comes time to call bar().

Should submethod bar() be called first, then method bar() after it?
Should method bar() be called first, then submethod bar() after it?

Can submethods only be called from within the class (like private 
methods)?

And if submethods can only be called from within the class, then how do 
I handle this:

class Foo {
	submethod bar { ... }
	method bar { ... }
	method baz {
		$?SELF.bar()
	}
}

Foo.new().baz()

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