Re: more .method (was: Perl 6 Summary for 2005-07-05 through 2005-07-12)

2005-07-14 Thread Larry Wall
On Thu, Jul 14, 2005 at 12:14:57PM -0600, John Williams wrote:
: Actually I took his question to be:
: 
: If I explicitly name my invocant in the method signature, does that give
: the compiler enough assurance that I'm not going to use .method to mean
: $?SELF.method, and it will allow me to safely use .method as $_.method in
: for and given?

That question also came up in the cabal's last telecon, and I basically
decided that it doesn't.  If you want those assurances, a single

use self;

would be sufficient, even if you don't use the default of "self", or
whatever self defaults to.

Or we might just go ahead and provide an explicit pragma dealing with
the .foo construct, but I'll be switched if I can come up with a decent
name for it.

use topic;

though arguably

use topic "it";

would tend to mean that you want to always use "it" for the topic and
leave .foo for $?SELF.foo.  So maybe if you say

use dot;

it defaults to

use dot '$_';

and in general says, "I know the heck what I'm doing about dot".

[From there our discussion digressed/descended into whether there
should be an "I am an expert" pragma.  I was dubious about any sort
of non-feature-based razor.]

Anyway, the people who always want to use .foo for self calls could
then say

use dot '$?SELF';

and then such programs could be plagued by self-dot.

Larry


more .method (was: Perl 6 Summary for 2005-07-05 through 2005-07-12)

2005-07-14 Thread John Williams
On Wed, 13 Jul 2005, Juerd wrote:

> Dave Whipp skribis 2005-07-13  8:44 (-0700):
> > >  Within a method or submethod, C<.method> only works when C<$_ =:=
> > > $?SELF>.
> > >C<.method> is perfectly legal on *any* topic anywhere that $?SELF
> > >doesn't exist.
> > Just to be clear, this includes any method/submethod with an explicitly
> > named invocant, I hope.
>
> No, $?SELF exists in every method. It's not the *default* invocant
> variable, it's the *always there* invocant variable. There is no default
> variable anywhere in the language that isn't $_.

Actually I took his question to be:

If I explicitly name my invocant in the method signature, does that give
the compiler enough assurance that I'm not going to use .method to mean
$?SELF.method, and it will allow me to safely use .method as $_.method in
for and given?

~ John Williams