Allison Randal wrote:
> 
> On Tue, Apr 09, 2002 at 09:56:02PM +0100, Piers Cawley wrote:
> > Larry Wall <[EMAIL PROTECTED]> writes:
> >
> > > We're talking about how to make .foo mean self.foo regardless of the
> > > current topic.
> >
> > Are we? I was looking for a way to unambgiously access the current
> > object in such a way that topicalizers would still work...
> 
> I think we were talking about both.

> I see two directions the solution could go in. Direction 1 is "if you
> don't like it, lump it". If you're going to need to access an outer
> topic within a nested topicalizer, you should define a named
> variable/parameter ("method icial ($self:..."). This is the path we've
> taken with other nested topicalizers.

Yes, yes, be explicit.  If the current topic is an object, its methods
get invoked by unary dot, be it inside a method or outside a method.

> Direction 2 moves into the more exciting but scarier realm of alternate
> defaults.

It could, but how about an alternative?

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.

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.

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
   }
}

-- 
Glenn
=====
Remember, 84.3% of all statistics are made up on the spot.

Reply via email to