diff options
author | Zefram <zefram@fysh.org> | 2009-11-08 15:03:45 +0100 |
---|---|---|
committer | Rafael Garcia-Suarez <rgs@consttype.org> | 2009-11-08 15:11:11 +0100 |
commit | f7461760003db2ce68155c97ea6c1658e96fcd27 (patch) | |
tree | 3ef60fff1e3763bb814eb07f408a34688546c026 /pod | |
parent | 6bd7445c6d3b53823883c456e32ea27ce24bfc5c (diff) | |
download | perl-f7461760003db2ce68155c97ea6c1658e96fcd27.tar.gz |
Bareword sub lookups
Attached is a patch that changes how the tokeniser looks up subroutines,
when they're referenced by a bareword, for prototype and const-sub
purposes. Formerly, it has looked up bareword subs directly in the
package, which is contrary to the way the generated op tree looks up
the sub, via an rv2cv op. The patch makes the tokeniser generate the
rv2cv op earlier, and dig around in that.
The motivation for this is to allow modules to hook the rv2cv op
creation, to affect the name->subroutine lookup process. Currently,
such hooking affects op execution as intended, but everything goes wrong
with a bareword ref where the tokeniser looks at some unrelated CV,
or a blank space, in the package. With the patch in place, an rv2cv
hook correctly affects the tokeniser and therefore the prototype-based
aspects of parsing.
The patch also changes ck_subr (which applies the argument context and
checking parts of prototype behaviour) to handle subs referenced by an
RV const op inside the rv2cv, where formerly it would only handle a gv
op inside the rv2cv. This is to support the most likely kind of
modified rv2cv op.
The attached patch is the resulting revised version of the bareword
sub patch. It incorporates the original patch (allowing rv2cv op
hookers to control prototype processing), the GV-downgrading addition,
and a mention in perldelta.
Diffstat (limited to 'pod')
-rw-r--r-- | pod/perl5112delta.pod | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/pod/perl5112delta.pod b/pod/perl5112delta.pod index ca8c8096ff..d6dad5dcb6 100644 --- a/pod/perl5112delta.pod +++ b/pod/perl5112delta.pod @@ -74,6 +74,16 @@ implements reverse Polish notation arithmetic via pluggable keywords. This module is mainly used for test purposes, and is not normally installed, but also serves as an example of how to use the new mechanism. +=head2 Overridable function lookup + +Where an extension module hooks the creation of rv2cv ops, to modify +the subroutine lookup process, this now works correctly for bareword +subroutine calls. This means that prototypes on subroutines referenced +this way will be processed correctly. (Previously bareword subroutine +names were initially looked up, for parsing purposes, by an unhookable +mechanism, so extensions could only properly influence subroutine names +that appeared with an C<&> sigil.) + =head1 New Platforms XXX List any platforms that this version of perl compiles on, that previous |