develooper Front page | perl.module-authors | Postings from November 2011

Naming a module that injects new code into a file's source at compile time

Thread Next
Eric Strom
November 1, 2011 14:28
Naming a module that injects new code into a file's source at compile time
Message ID:
I am working on a module and set of tools for injecting source into
another file at compile time.  It currently does this by using
Filter::Util::Call to hook into the compilation process, inject the
new code before the next line that perl will compile, and then remove
itself handing control back to the compiler.

I have tentatively named this module ``

   use eval 'my $x = 1';

   use eval some_sub(...);

since `use` implies compile time and it is injecting the source into
the currently compiling `eval`.

but I am considering any of the following names:

   eval         (my preference)

Since all of these names are single word/lowercase names, I wanted to
put the name up for the Perl community to comment on.

While not a pragmatic module in and of itself, the primary usage is to
insert declarations and other code elements that are otherwise
impossible to import (package declarations, my/our lexical
declarations, ...).  So due to this behavior, a lowercase name seems

The overall goal of the module is to allow people to write a macro function:

    sub my_0 {map "my \$$_ = 0", @_}

And then be able to write:

    use eval my_0 qw(x y z);

And have the compiler see `my $x = 0; my $y = 0; my $z = 0;`

These macro functions can of course be of any complexity, but their
scope is limited to the supplied arguments, and not to the source file
at large, as would be the case with a normal source filter.

I have a fully written module with a decent test suite ready to upload
once the name is finalized.

This question was first posted to, and Steffen
Mueller pointed me here.  This was the first posting:

Thanks for your time,

Eric Strom

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