On Monday, October 14, 2002, at 10:28 AM, Larry Wall wrote:
> On Mon, 14 Oct 2002, Larry Wall wrote: > And I should point out that this approach would be good not just for > type purity, but because it optimizes for the common case. Class > methods > are much rarer than instance methods. And the class-or-instance > approach > seems to be even rarer than ordinary class methods, in practice. Of course, in hindsight. So we have three cases to deal with: - a method that can only take an instance (80% of the time?) - a method that can take only a Class (15% of the time?) - a method that can deal with both (< 5% of the time?) The first two are well-understood and common behaviors, and probably shouldn't force you to declare the invocant at all. The third form is almost never what you mean (except in constructors and a few other places) and should be discouraged compared to the other two. In a message dated Sun, 13 Oct 2002, Piers Cawley writes: > I like that idea: > > class SomeClass { > method class_method ( Class $class : ... ) { ... } > method instance_method ( SomeClass $self : ... ) { ... } > method dont_care_method ( $self : ... ) { ... } > } So if the first two should be shorter than the third, one way to do that would be something like: class SomeClass { cmethod class_method {...} # via a keyword method instance_method {...} # via another keyword sub dont_care_method {...} # check it yourself, as 1st arg } Except for the fact that the word 'cmethod' is not a terribly intuitive choice. In general, I'd vote for making the distinction through a keyword rather than through more subtle hints: it seems the shortest way to say what you mean, and the first two cases are certainly common enough to justify them. Trying to put the distinction in the method name itself makes me worry that other things are going on, like implicit typecasting or something: method SomeClass.class_method {...} And putting it in the argument list makes me think at first glance that it's an argument, but not necessarily an invocant: method class_method ( Class $class : ... ) { ... } .... (looks a lot like) ... method class_method ( Class $class, ... ) { ... } which, I assume, does something completely different. MikeL