On Wed, Apr 10, 2002 at 10:30:25AM -0700, Glenn Linderman wrote:
> Allison Randal wrote:
> > 
> > Direction 2 moves into the more exciting but scarier realm of alternate
> > defaults.
> 
> It could, but how about an alternative?
 
Ah-ha, yet a third Direction!

> Need there be a unary dot to specify invocation of an alternate method
> in the same class as the method being compiled?  In other words, the
> following rules:
> 
> 1) A method implicitly defines the default topic to be the object on
> which it was invoked.
 
As has been mentioned, this is already true.

> 2) Unary dot uses the default topic as the object on which to invoke
> methods.  If the default topic is not an object, an exception results.
 
Well, since all the variable types are now objects, which have methods,
this wouldn't happen. But you would get some sort of exception if there
was no method of that name for the current object.

> 3) The function call name space within a method is first other methods
> of the same class, then other functions.  (This is similar to C++, I
> believe)
> 
> Hence, given a class containing two methods m1 and m2...
> 
> method m1
> {
>    m2;  # calls method m2 in the same class
>    & m2;  # this should do the same, if the & is still permitted
>    .m2;  # syntax error
>    given ( $other_object )
>    {
>        when m2 { ... }   # invokes method m2 in the same class
>        when .m2 { ... }  # invokes $other_object.m2
>        when $_.m2 { ... }  # invokes $other_object.m2
>        when $self.m2 { ... }  # syntax error, unless some "use invocant
> self"
>                               # directive is included somewhere in the
> scope
>                               # If it is, then invokes method m2 in same
> class
>    }
> }
> 

I kind of like the idea of having both "topic" and "invocant" available
at all times. But, I am concerned at having such a huge semantic
difference (which object you're using) relying on the subtle visual
distinction between m2() and .m2(). I can see a large opportunity for
coder error and newbie misunderstanding. You also lose the visual cue
that says "this is a method call, not a subroutine or a built-in
function". In the end I think that might be more confusing than it's
worth.

Allison

Reply via email to