You probably noticed the can and does ops. The intent here is to
provide the capability to check whether an object can perform a
method by name, or implements an interface.
Interfaces, for folks that only do perl OO, are sets of methods, and
single-inheritance languages tend to use them as a way around not
having multiple inheritance. (The same way that MI languages tend to
use MI to get around not having interfaces) They're also known as
mixins, IIRC.
The point here is to allow checking to see if a class provides a
particular set of functionality without having to check each method
you're going to use. This is both faster, which is good, and avoids
potential whoopses when can returns misleading info, because an
object does have a method of the name you're checking, it just means
something completely different than what you intended.
No, perl 5 doesn't do them. I don't know if perl 6 will, though I
expect it might. Ruby, Java, and Objective-C do. (ObjC calls 'em
protocols, and they're relatively informal)
Not a panacea, but one more tool for the toolbox...
--
Dan
--------------------------------------"it's like this"-------------------
Dan Sugalski even samurai
d...@sidhe.org have teddy bears and even
teddy bears get drunk