Trey Harris wrote:
> 
> 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 : ... ) { ... }
> >    }
<snip>
> And I don't think you can do multiple-dispatch on topic, can you?

MD on topic could probably be easily allowed: sure, it's an invisible
argument, but it's still a parameter of the method invocation -- and
therefore internally could/should be a part of the method's full
signature.  The syntax might get scary, tho.

My temporary hack while writing the proto-recipes was that we'd have a
property that would simply declare a method to be a class method, but
I'm having a hard time coming up with an acceptable name to suggest for it:

        method foo is class_method { ... }              # ???

It feels, conceptually, like something that should be a property.  The
other possibility is to use a keyword other than "method" for class
methods, but that would also require us to think of a word (and would
probably just be shorthand for a named property anyway).  So, I haven't
been able to come up with a single decent noun or adjective that means
"class method", so far.  (classwide? static? blind? classmeth? cmethod? classorific?)

Regardless of how we declared it, my operating theory was that any
method declared as a class method would automatically be able to take
either a class or a class instance as it's invocant, and do the right
thing (i.e. when using an instance to invoke a class method, it would
automatically convert it to a class before assigning it as the topic, so
the implementing method wouldn't even notice, unless it went out of it's
way to look.)

This would DWIM, would mean we don't need multiple dispatch for it (at
least not in visible form) and would be in line with the common perl5 strategy:
        $class = ref $class if ref $class;

If you *did* want a method that treated invoke-by-classname and
invoke-by-instance differently (i.e. a constructor), you simply wouldn't
declare it as a class method, and have the method check the topic itself.

MikeL

Reply via email to