This drifed off list but I don't think that was intentional.

----- Forwarded message from Yuval Kogman <[EMAIL PROTECTED]> -----

From: Yuval Kogman <[EMAIL PROTECTED]>
Date: Fri, 18 Mar 2005 01:12:42 +0200
To: Michael G Schwern <[EMAIL PROTECTED]>
Subject: Re: .method == $self.method or $_.method?
User-Agent: Mutt/1.5.6i

On Thu, Mar 17, 2005 at 14:42:06 -0800, Michael G Schwern wrote:
> Because $_ can change.
>       method bar ($_:) {
>               .foo;
>               map { .baz } 1..10;  # whoops
>       }

I don't see it as a whoops. It's either or, and the user gets to

I read that as:

        method bar ($self:) { for ($self) {

BTW, given:

method bar {
        # what's $self named in here?
        # do you need to name it for it to be accessible?

S12 does not specify, as far as I can tell.

Perhaps the desired behavior could be: If the invocant is not
specified it is the default, i.e

method bar {


is really

method bar ($_:) {


and the user assumes responsibility for not resetting $_ if they
would like to keep it.

> As I understand it, $invocant.method and $.method are different.  The first
> is a public attribute the second is a method call, no?  And while all
> attributes have an associated method (as I understand, ie. foreach $.foo, 
> $ should always be the same) the reverse is not true.
> Foreach $ there need not be a $.foo.

I think you are right... But here is an idea:

The only conflict I see with the reverse not being true is if you
would like to avoid calling the is rw accessor when you want to set
the attribute from within the class.

This assumes that $.attribute = ... from within an accessor means
the attribute itself, as a special case, and that all accessors are
rw when their caller is eq ::?CLASS.

Again, the problem is that an accessor that is rw and does funny
stuff to it's attribute could not be avoided when a sibling method
wants to just fudge the attribute.

On second thought, this problem seems bigger now. Opinions?

 ()  Yuval Kogman <[EMAIL PROTECTED]> 0xEBD27418  perl hacker &
 /\  kung foo master: /me beats up some cheese: neeyah!!!!!!!!!!!!!!!!!

----- End forwarded message -----


Reply via email to