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:
Zefram
Date:
January 20, 2011 19:05
Subject:
Re: [PATCH] use feature 'method'; (was Re: Proposal: "$->" forimplicit invocant)
Message ID:
20110121030520.GD5868@lake.fysh.org
chromatic wrote:
>How do you use keyword hooks to add 'method' to the imports of feature.pm?

You don't.  But there's no reason for your particular version of "method"
to be controlled by feature.pm.

> * grabbing the optree *already generated* for the body of the sub

No.  You add the pad entry *before* parsing the body.  It's not as
difficult as you make out.

>                                                             You could use as 
>much existing code as possible (code that knows how to build an optree, code 
>that knows how to create lexicals, code that knows how to decide $self is 
>lexical, et cetera).

The code that you're referring to there doesn't just generate ops and pad
entries, it also parses general Perl code, in which (for example) "shift"
could mean all sorts of things.  Using lex_stuff, your implementation
is liable to be broken by local redefinition of a keyword that doesn't
appear in the user's source.  That's OK for a prototype, but not at all
OK for a serious language feature.

-zefram

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