Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^3: what would you like to see in perl5.12?

by BrowserUk (Patriarch)
on Aug 21, 2007 at 15:28 UTC ( [id://634110]=note: print w/replies, xml ) Need Help??


in reply to Re^2: what would you like to see in perl5.12?
in thread what would you like to see in perl5.12?

Actually yes. That would solve this problem, and several other similar ones.

Given that whatever was put in place would have to remain notionally backwards compatible--which probably means any new interpolation mechanism is a non-starter but---I'd probably go with:

"some stuff {{ any perl expression here }} more stuff"

Indeed, if I'd been spec'ing Perl 6 interpolation, I think I would have removed all other interpolations in favour of a single 'interpret the block and substitute whatever it produces in its place' construct.

It mildly complicates the simple case " xxx{{ $var }}xxx" instead of "xxx${var}xxx", but in the general case, it would be no more complicated than "xxx@ary[]xxx" or "xxx%hash{}xxx", and the consistancy would greatly simplify the parser.

Indeed, the parsing would become simple enough that most editor syntax highligher parsers would probably be able to pick out embedded interpolation blocks, making them stand out from the surrounding string, and even highlight the embedded code in the usual manner.

For me, the ability to have my editor highlight interpolations, (without resorting to running a second OS as an editor:), would more than make up for the slightly less convenient syntax it would require for the simple case.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^4: what would you like to see in perl5.12?
by blazar (Canon) on Aug 26, 2007 at 11:49 UTC
    Indeed, if I'd been spec'ing Perl 6 interpolation, I think I would have removed all other interpolations in favour of a single 'interpret the block and substitute whatever it produces in its place' construct.

    Oh no! Perl 6's new quoting mechanism, with everything based on a single C<Q> and a bunch of adverbs is just breathtaking: it is at same time simple, intuitive and powerful as familiar constructs like C<q> and C<qq> will remain very much the same as in Perl 5 and a terrible amount of more flexibility will be available at the tiny expense of appending a semicolon and a few letters. Or in some cases no colon at all and a single letter.

    For me, the ability to have my editor highlight interpolations, (without resorting to running a second OS as an editor:), would more than make up for the slightly less convenient syntax it would require for the simple case.

    Oh well, that's hardly a problem for me so we definitely see things from two very different perspectives. Personally, I find too much syntax highlighting to be distracting, but when I find it... ehm... desirable. (Speaking of strings, in current Perl, e.g. when the necessary evil of a string eval of a considerable amount of code is needed and then I use q{...} or qq{...}.)

    Yet it seems to me we could still have the best of both worlds: if e.g. C<qq> implies :s, :a, :h, :f, :c and :b you may still stick to only interpolate {...} expressions when you want them to be syntax highlighted, and your editor may do a good job of doing so.

    Or if you want to stay very strict, then you may get into the habit of doing:

    macro qbuk { Q:c:b }
      with everything based on a single C<Q> and a bunch of adverbs

      I don't understand what you mean by "based on a single c<Q>"?

      And I'd just point out that the adverbs could still be used with "...{{ code }}:x ...".


      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.
        I don't understand what you mean by "based on a single c<Q>"?

        <joke>It is not in my realm of competence to know whether you understand or not.</joke>

        Seriously, to quote from Synopsis 2:

        And I'd just point out that the adverbs could still be used with "...{{ code }}:x ...".

        Adverbs within the quoted material? A completely different thing: adverbs on (quote-like) operators define how the "language" in the quoted material is interpreted. What you're talking about would be a feature specific of one such language. (Speaking of which I suppose it will be possible to define your own parser switching adverbs, along with an appropriate parser.)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://634110]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (6)
As of 2024-04-23 11:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found