Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Alias (5735)

  (email not shown publicly)

Journal of Alias (5735)

Sunday June 12, 2005
08:03 AM

PPI 0.992 released. New PPI::Transform API

[ #25159 ]

So after dealing with Perl::Squish and associated problems, I'm wondering briefly this afternoon how the hell I'm going to get PPI::Transform, the API from hell, done any time before the 1.000 release I want to do for OSCON.

PPI::Transform is meant to be the API for writing classes and objects that munge PPI::Documents, in a way that is usefully like File::Find::Rule enough to allow for passing transforms around, combining them together, and doing other neato things.

And it's a bitch. I've written and thrown it away no less than 6!!! times.

So this afternoon it occurs to me that Perl::Squish has sort of the right approach to this.

But that approach is not going to be able to do things like this.

$Transform->apply( $SomeObject )

Buuuuut... with a working $Transform->document($Document) command, all we'd need to do is get some random object to be a PPI::Document and then back again.

So 3 hours of hacking up a PPI::Transform ->apply registration system, we now have a shiny new PPI::Transform API.

What's really great about this is how adaptable it should be.

For example, imagine an editor that you could register your own transform command for.

"Clean up Whitespace" --> "Perl::Cleanwhitespace"

Perl::Cleanwhitespace would be a PPI::Transform subclass. The editor only has to create a default Perl::Cleanwhitespace object, and then pass a reference to SCALAR to it containing the contents of the currently open document, and everything will happen magically!

THIS means that you should now be able to write your own transform classes VERY easily, and they will be compatible with ANY editor that knows how to talk to the PPI::Transform API.

I look forward to writing my own transform classes I can move from editor to editor :)

Yeah baby!

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • This sounds very interesting.

    Is there any work done, or thoughts about, handling many Perl documents, i.e. something that looks more like an entire Perl application?

    I'm primarily thinking along the lines of refactoring, code navigation etc. where this would be useful.