Paul Seamons wrote:
To sum up...
If you are in a method then you get .method and it always works even if $_ is
rebound to something else.
I also have problems to perceive .method beeing bound to $_ from a
typing point of view: $_ is a dynamic variable in the runtime
environment, while the method is compiled in a class' scope. From
type theory a class should be understood as a type generator with
its $?CLASS as an implicit parameter. That means in subclasses the
invocant has the subclass type even when the method is not redefined.
That's basically a complicated way to say that all methods in Perl6
are virtual in the C++ sense ;)
So every .method would be bound to an invocant of the class type at
compile time! At that time there is no implicit $_ yet. And the set
of methods should be known to the compiler, BTW. I even doubt the
usefullness of $_ in methods: it's way too far away from the
(runtime) context. After all, OOP is about dealing with the class
and parameter environment in methods only, and it's easy to grep
the topic by means of the 'is topic' parameter trait---and call the
variable $_ if wanted.
Only in code that is outside of classes---that is subs and top level
statements (what about rules?)---method calls are compiled such that
they are invoked on $_ and the only question is if this usage might
be written without explicit $_ or if this is too easily mixed with
class coding. But I think that a programmer knows if he's in method
scope or not. OTOH, copy and paste of lines might change meaning
without the compiler having a chance to detect it!
TSa (Thomas Sandla▀)