develooper Front page | perl.perl5.porters | Postings from January 2011

Re: [PATCH] use feature 'method'; (was Re: Proposal: "$->" forimplicit invocant)

Thread Previous | Thread Next
From:
David Golden
Date:
January 20, 2011 12:15
Subject:
Re: [PATCH] use feature 'method'; (was Re: Proposal: "$->" forimplicit invocant)
Message ID:
AANLkTin_GenVxHNugEJhS9X+OnEge9oyJpz9fmrULd2m@mail.gmail.com
On Thu, Jan 20, 2011 at 2:28 PM, chromatic <chromatic@wgz.org> wrote:
>  * grabbing the optree *already generated* for the body of the sub
>  * creating a new lexical $self binding in that optree
>  * rummaging through every variable access in that entire optree to find $self,
> if it exists

This is why I was pondering a "self" keyword.  If it could access the
right reference at runtime you wouldn't need to worry about the
existing bindings.

Imagine:

   * method { ... } somehow marks the subroutine body as a method
   * dispatch to such a marked method doesn't put the invocant in @_
but puts it "somewhere else" (big hand-waving here)
   * keyword self retrieves invocant from wherever it got put

I leave it to people who know the guts in detail to explain why that
is doomed to fail. :-)

-- David

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About