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

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

Thread Previous | Thread Next
From:
Steffen Mueller
Date:
January 20, 2011 13:43
Subject:
Re: [PATCH] use feature 'method'; (was Re: Proposal: "$->" forimplicitinvocant)
Message ID:
4D38AC60.9060907@cpan.org
On 01/20/2011 09:14 PM, David Golden wrote:
> 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

"wherever" would likely still be the stack, except @_ is populated only 
with the elements after the invocant.

The little understanding I have of these matters suggests that arguments 
will be passed via the stack no matter what and @_ is then "aliased" 
(SV* copy? Too lazy to check.) to the elements since the last pushmark. 
If there was a flag to start only after the first element and make the 
sp accessible via "self" by some mechanism, that might just do it.

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

Yes, it is now up to them :)

Cheers,
Steffen

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