On Fri, May 27, 2005 at 10:59:25PM +0200, Ingo Blechschmidt wrote: : Hi, : : what is the default invocant of methods? : : method blarb ($normal_param) {...} : # Same as : method blarb (Class | ::?CLASS $invocant: $normal_param) {...} : # or : method blarb (::?CLASS $invocant: $normal_param) {...} : # ? : : I prefer the latter, as then one can't accidentally call a instance : method on the class -- i.e. : Foo.blarb # will die.
It will almost certainly die anyway the moment you try to do something instancely with it. : You can always specify Class as invocant, if you want to have a class : method. Hmm, well, maybe, provided Class is the parent of all possible class classes, but it's not entirely clear we want to assume that. We could get potentially get other kinds of metaclass and dispatcher classes involved, especially if we've inherited things across languages. At some point you have to trust your dispatcher to hand you things you can work with, and that may involve some kinds of structural or role equivalence rather than just class name equivalence. Hmm, maybe Class is really a role then, and anything that "does Class" can pretend to be one. : Opinions? >From the efficieny viewpoint, I'd rather leave it untyped, and rely on the dispatcher to do my type checking. Of course, there are times you'd like the compiler to know that the type of $?SELF is consistent with the current class, but that's a different matter than run-time type checking, which an explicit type tends to imply. Larry