diff options
author | Jesse Vincent <jesse@bestpractical.com> | 2009-11-05 11:14:45 -0500 |
---|---|---|
committer | Jesse Vincent <jesse@bestpractical.com> | 2009-11-05 11:14:45 -0500 |
commit | 88e1f1a2657a3a28cf3a7811902a09aca9e18986 (patch) | |
tree | e7280ddd6c04915543c3850e403d06b8b5892524 /pod/perl5112delta.pod | |
parent | 9b583d5830e4b19cc53ab2180c0fd30418e764ed (diff) | |
download | perl-88e1f1a2657a3a28cf3a7811902a09aca9e18986.tar.gz |
Implement facility to plug in syntax triggered by keywords
Date: Tue, 27 Oct 2009 01:29:40 +0000
From: Zefram <zefram@fysh.org>
To: perl5-porters@perl.org
Subject: 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.
[This commit includes the Makefile.PL for XS-APITest-KeywordRPN missing
from the original patch, as well as updates to perldiag.pod and a
MANIFEST sort]
Diffstat (limited to 'pod/perl5112delta.pod')
-rw-r--r-- | pod/perl5112delta.pod | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/pod/perl5112delta.pod b/pod/perl5112delta.pod index 4d524670b3..ca8c8096ff 100644 --- a/pod/perl5112delta.pod +++ b/pod/perl5112delta.pod @@ -52,6 +52,28 @@ boolean, string or number of objects. It is invoked when an object appears on the right hand side of the C<=~> operator, or when it is interpolated into a regexp. See L<overload>. +=head2 Pluggable keywords + +Extension modules can now cleanly hook into the Perl parser to define new +kinds of keyword-headed expression and compound statement. The syntax +following the keyword is defined entirely by the extension. This allow +a completely non-Perl sublanguage to be parsed inline, with the right +ops cleanly generated. + +This feature is currently considered experimental, and using it to do +anything interesting is difficult. Many necessary supporting facilities, +such as the lexer and the pad system, can only be accessed through +unsupported internal interfaces. It is intended that the Perl 5.13 +development cycle will see the addition of clean, supported interfaces +for many of these functions. In Perl 5.12 most uses of pluggable keywords +will be via L<Devel::Declare>. + +See L<perlapi/PL_keyword_plugin> for the mechanism. The Perl core source +distribution also includes a new module L<XS::APItest::KeywordRPN>, which +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. + =head1 New Platforms XXX List any platforms that this version of perl compiles on, that previous |