Well, I realized that I really need acceptance rather than awareness. CPAN and discussions take care of the latter. So, since this is supposed to do everything Exporter does as just a jumping off point, then add new features, my idea was to provide an automatic translation tool.
So, I wrote Exporter-VA-Convert (see docs here, last time I tried to paste the generated HTML into a perlmonks node it didn't quite work out right). This loads the module and then examines the resulting package globals that Exporter::import uses. It can't really rewrite the source code because it never directly parsed it. It only cares about the resulting value, not how it was computed, so just loading and letting the module's logic take care of itself seems like a great thing to do. But, instead of changing the code, it tells you what definitions to change, delete, and insert.
This generates a Exporter::VA export definition with the same meaning, including default exports, OK exports, and taglists. It also sets up callbacks and gives you the skelleton for the sub (though it can't write it for you) if it detects @Exporter::EXPORT_FAIL. It also checks to make sure the module is using Exporter in the normal way in the first place, detecting custom imports and other funny things.
It was very interesting to write this kind of introspective code. It resulted in a few questions to this forum, too, including the code ref issues and digging into Data::Dumper.
Now this conversion utility just makes an exact conversion with the same meaning. The next step is to offer some switches to change that, since the whole point of "upgrading" to Exporter::VA is to take advantage of its particular features. In particular, getting rid of default exports while retaining backward compatibility. So I think I'll have a switch to generate separate old and new default export lists with the new being empty, and then you can edit that, pasting in stuff copied from the old one if you don't plan to get rid of all of them. Perhaps the switch should let you specify any tags you want versioned.
On a more cosmetic note, I'd love to have a more compact qw/ ... / output instead of the fully quoted, one word per line generated by Data::Dumper.
Well, what do y'all think of these ideas?
—John
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: My module - my latest step
by Juerd (Abbot) on Jan 06, 2003 at 14:44 UTC | |
by John M. Dlugosz (Monsignor) on Jan 06, 2003 at 17:13 UTC | |
|
Re: My module - my latest step
by toma (Vicar) on Jan 08, 2003 at 07:34 UTC | |
by ihb (Deacon) on Jan 11, 2003 at 19:39 UTC | |
by toma (Vicar) on Jan 11, 2003 at 21:23 UTC | |
by Aristotle (Chancellor) on Jan 11, 2003 at 17:43 UTC |