develooper Front page | perl.perl5.porters | Postings from August 2013

Re: [perl #119455] [EXPERIMENT] pluggable keyword API

Thread Previous | Thread Next
August 28, 2013 21:24
Re: [perl #119455] [EXPERIMENT] pluggable keyword API
Message ID:
Lukas Mai wrote:
>1) There's no documentation that tells you how you actually integrate it
>in a distribution.

Yeah.  That bit's tricky.  ExtUtils::CBuilder really isn't set up to
get the linking right on Windows.

>What exactly is "prior"? Do I do this once and check the file in? Or is
>this supposed to run as part of the build process

You generate the header during the build process.  The header is specific
to a particular Perl version.

>                                                  (in which case, how do
>I extend the Makefile to make it do that)?

That's between you and ExtUtils::MakeMaker.  I've never done it that way;
I use Module::Build.

>                                           Or is this supposed to run at
>configure time

You can if you like, but then D:CP would be a configure_requires.

>2) Function::Parameters is a lexical pragma. Does D:CP provide lexical

No, D:CP does not address exporting.  It just attaches magic to a
subroutine object, and you export that by whatever means you like.

For a while I thought lexical exporting was the way forward.
But actually, whether lexical scoping is desired is more a feature
of the *im*porting module, the one that owns the affected namespaces.
And we've got a huge base of existing modules that follow the established
protocol of exporting to the calling package.  We're not going to get
pervasive lexical scoping implemented from the exporting side.

I therefore wrote Lexical::Import, which interfaces to a standard
export-to-package module and puts the exported items into the lexical
namespace.  It uses Lexical::Var underneath to implement the lexical
scoping.  This includes lexical scoping of subroutine names, even though
"my" doesn't offer such a facility.

(If you have a backcompat requirement to lexically export from a
particular module, you can do it by using Lexical::Var directly from
the "import" method.  I suggest that you shouldn't lexically export,
in general, if you don't have such an established API to maintain.
I actually switched Scope::Escape::Sugar incompatibly from lexical
exporting in 0.000 to package exporting in 0.001.)

So you see my recommended mechanism involves composing a bunch of modules
that concentrate on small parts of the job.  D:CP to hook parsing;
cv_set_call_checker to hook op generation; Exporter to publish the magic
subroutine; and Lexical::Import to import it into a lexical scope.


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