Re: RFC for $ME class variable (was Re: RFC 124 (v1) Sort order for any hash)

[email protected] (Damian Conway)
Newsgroups perl.perl6.language.objects
Message-ID <[email protected]>
   > > It's an idea that within a method call, the object reference would
   > > not be passed as the first argument (or maybe, not *just* as the
   > > first argument), but in a variable named $ME. I was pushing that
   > > envelope a little.
   > 
   > Is this RFC'ed yet? 
   
It may have been mentioned in Andy Wardley's treatise, but I think
it warrants it's own RFC.

   > If not, I'll do it

Fine by me.

   > I think that $ME should NOT be passed in @_ at all. It's a PITA right
   > now to deal with (function vs. object forms, trying to support both).
   > $ME should simply be the name of the class it's called as a member of,
   > falling back to the name of the package if one isn't defined (as in a
   > function-oriented style).

Errr. I would imagine that $ME contains:

	* a reference to the object, within an object method

	* the name of the class, within a class method

	* a reference to the *subroutine* itself, within a non-method.

   
   > P.S. Alternatives to $ME are welcomed, but please email these JUST to
   > me. Naming always seems to generate tons of messages. I'll just list the
   > alternatives under "alternative names" at the bottom of the RFC. Thanks.

Don't give alternatives. Give a "these alternatives were considered and
*rejected*" list. $ME is capitalized (like all "magic" vars), and short.

And don't forget to include my idea that $ME be scoped locally like
$AUTOLOAD, so that the "self" and "this" and "I" and "myself" camps can
have their respective cakes but the rest of us don't have to eat them:

        package MyClass_Std;

        sub name($newval) {
                $ME->{name} = $newval if @_;
                return $ME->{name};
        }


        package MyClass_Selfish;

        sub self() {$ME};

        sub name($newval) {
                self->{name} = $newval if @_;
                return self->{name};
        }


        package MyClass_Thisly;

        sub this() {$ME};

        sub name($newval) {
                this->{name} = $newval if @_;
                return this->{name};
        }


        package MyClass_ValleySpeak;

        sub me_myself_personally() {$ME};

        sub name($newval) {
                me_myself_personally->{name} = $newval if @_;
                return me_myself_personally->{name};
        }


:-)

Damian
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.