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

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.
  • by bobtfish (8386) on 2009.06.19 13:08 (#69110)

    I guess that your example above is a gross simplification of what you're actually trying to do?

    In fact, re-reading your post, you say:

    While I now know that I can just use Moose::Meta::Class to do this, but this is actually a problem I encounter from time to time in other contexts and rather than explicitly doing a string eval (which breaks syntax highlighting and hides the code from PPI), I'd like that 'repackage' to handle that.

    As I'm sure you know, your example above can be written as:

    Moose::Meta::Class->create( $some_package. superclasses => 'Some::Class', roles => 'Some::Role', );

    So what is actually stopping you from just doing that, I don't understand?

    I mean, you say other contexts, but if you're explicitly using roles, then you're making Moose classes anyway - so I don't see how it's a different context.

    If you're just using more plain perl OO, then I'd be tempted to just use Class::MOP::Class->create instead.

    If you really want to play with Devel::Declare just cause you want to play - fair enough however ;) In that case, I recommend that you look at Method::Signatures::Simple, which is already implementing your case (i.e. defining a keyword, and prependng / appending some stuff)...

    • When I say "other contexts", I just mean that I do a lot of code generation work and I often need to dynamically declare a package. Deferring code compilation via eval is a common enough thing in general that I think it's worth generalizing it.