Subject: | Lexical analysis of modules using 'use syntax' does not reveal true dependencies. |
I hesitate to call this a bug - it's more of a general caveat for users
of "syntax" that should probably be documented somewhere. If I write a
package like this:
{
package Local::Thing;
use syntax qw/ function perform /;
# ...
}
Then tools like Module::Install::Metadata which perform lexical
analysis (i.e. in practice regexps) of my source code will notice that
it depends on the syntax module, but not that it depends on
Syntax::Feature::Function and Syntax::Feature::Perform.
As I said, this isn't a bug, but a consequence of the design of
"syntax", and it really just exposes the fundamental problem with using
lexical analysis to determine requirements. Nevertheless, I think it
needs to be mentioned in the syntax pod, to warn people.
One way to help alleviate the problem would be to bundle a script along
the lines of "mo-inline" that Ingy includes with "Mo". The script would
search through a Perl file, find lines like this:
use syntax qw/ function perform /;
And replace them with blocks like this:
BEGIN # use syntax qw/ function perform /;
{
use Syntax::Feature::Function qw();
Syntax::Feature::Function->install(into => __PACKAGE__);
use Syntax::Feature::Perform qw();
Syntax::Feature::Perform->install(into => __PACKAGE__);
}
Thus removing the dependency on "syntax" itself, and making the
dependencies on the individual syntax features more explicit.
Another solution would be to submit patches to things like
Module::Install::Metadata to help them cope better with syntax.