Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Recently there has been quite a hype about syntax extensions to Perl that don't work via traditional source filters, but through Devel::Declare.

Lots of people who wouldn't touch source filters now write such syntax extensions like MooseX::Declare, and they seem to be well accepted.

However I still have some measure of reserve towards them, which I'd like to discuss with you. There are basically two reasons why source filters are wildly considered very evil™:

  1. Source filters have to parse Perl code. This is very hard, so sooner or later they fail, leading to errors which are very hard to track
  2. Since source filters have to parse Perl code themselves, you can't generally combine two source filters, even if they change different parts of the syntax

Now I read that Devel::Declare only hooks on barewords, and use the built-in parser for the rest.

But still the syntax changing module has to parse something. For example MooseX:::Method::Signature allows things like:

method hello (Str :$who, Int :$age where { $_ > 0 }) { ... }

It is my hope that the where-block allows arbitrary Perl code. Is that true? And if so, is the "real" Perl parser used for parsing it? And if yes, can other syntax changes based on Devel::Declare be used in this block?

If the answer to all three questions above is "yes", then I'm happy to acknowledge that Devel::Declare is really a good thing, and worth using (and actually comes quite close to "real" macros, except in scope of what can be changed).

If not, I'd argue that D::D based syntax changes are only gradually less evil than source filters, not conceptionally less evil.

What do you think? Does anybody have experience if D::D based syntax changes are really robust?

Update: tye++ pointed me to the reviews of TryCatch, which says

Great module for try/catch sugar in perl. I love pairing it with Moose::Util::TypeConstraints to have type based exception handling. Make sure that you have the latest Devel::Declare or you can have some weird issues that won't seem to make any sense.

The last sentence seems to suggest that it's not robust, or at least it was not. Still the question remains if it's a conceptional fault, or merely a lacking implementation right now.

Perl 6 - links to (nearly) everything that is Perl 6.

In reply to Is Devel::Declare really so much less evil than source filters? by moritz

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (1)
As of 2024-04-25 00:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found