Paul Seamons wrote:
 meth foo {
    $_.meth; # defaults to the invocant
    .meth; # operates on $_ which defaults to the invocant
    $^.meth;  # is the invocant
    $^1.meth; # is the first invocant
    $^2.meth; # is the second invocant

I'm starting to get confused at the "need" for all these special variables. I vote that we steal from prior art in numerous other languages and just auto-set $SELF or $THIS or whatever and call it done.


The problem is that there is no globally safe name to use that uses letters only. Also there is a certain line noise problem (which may not really be a problem - but looks like one once we have a more concise alternative):

I understand the purported problem, but what I'm saying is that it really isn't one. Variables magically coming into existence doesn't seem to be a problem for any language but Perl 6. Many other languages set "this" automagically.


> method foo {
>   $SELF.prop = $SELF.meth($SELF.get_foo, $SELF.get_bar);
>   $SELF.say("Hello " ~ $SELF.prop);
> }

I'm not sure the point of this block; it's hardly horrific. Any external script would have to say:

   $invocation = new Class;
   $invocation.meth($invocation.get_foo, $invocation.get_bar);

If the point is that $^ saves typing over $?SELF then I agree; my point is simply that we pick one or the other, instead of both/aliases/etc.

-Nate

Reply via email to