On Mon, May 02, 2005 at 11:29:49PM +0300, wolverian wrote: : On Mon, May 02, 2005 at 06:22:03PM +0200, Ingo Blechschmidt wrote: : > &.foo # method of $?SELF : > .foo # method of $?SELF : > $_.foo # method of $_ : : We could also define them as: : : &.foo # method on $?SELF : .foo # method on $_ : $_.foo # method on $_ : : The .foo syntax is very special, after all, so you can't really be : consistent with it. I prefer it be the topic, in any case.
We're still discussing it on @Larry, but I think we can make that work. There are some ambiguities with &.foo that depend on the declaration of it, but those can probably be resolved based on that declaration. This proposal is also consistent with the first invocant setting the topic, so "when" still works inside a method. So paint me back into the ".foo == $_.foo" camp this week, and now the ".foo == $self.foo" camp can start carping again. :-) By the way, this probably goes along with a policy of allowing $.foo, @.foo, and %.foo outside of the class as well. These would not refer to the actual attribute, but would call $self.foo() underneath (except in the class that actually defines the attribute). It seems to me that this would facilitate cut and paste of code, as well as the possibility of moving the attribute declaration to or from parent classes transparently. (To give credit where it's due, this was inspired by someone's misreading of S12 on PerlMonks a month or so ago.) Since the compiler is figuring out whether $.foo means an attribute or a method call on your behalf, to force a virtual call in the class itself, you'd have to say $self.foo(), which seems like a decent safety feature to me, insofar as it makes it harder to accidentally call yourself in an infinite regress. Which probably means that (just like $.foo) the &.foo is devirtualized in any class that defines method foo, or we're back to the too-easy infinite regress. I think it probably works... Larry