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

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

Thread Previous | Thread Next
January 20, 2011 19:05
Re: [PATCH] use feature 'method'; (was Re: Proposal: "$->" forimplicit invocant)
Message ID:
chromatic wrote:
>How do you use keyword hooks to add 'method' to the imports of

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

> * 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.


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About