-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proposal: q:thru/DELIM/ heredocs #282
Comments
In the VCard example, is it an accident (or significant) that the |
Actually, that's a bug I hadn't noticed, until now. Will update example. Thanks |
Since it was mentioned on IRC, this type of XML would NOT qualify for this heredoc. <root><section><item ./></section></root> Since the terminator is not on its own line. |
Indeed. Also, even in the case where it is, we have to repeat the terminator in two places, which doesn't feel all that ideal. If we want to change the XML tag we're using, we have to remember to update the terminator too, which is not the best bit of ergonomics. Syntax that looks good at rest doesn't always feel good in motion. One thing I don't see in the proposal is how this addition makes things better. In the negative column:
In the positive column:
For such naturally terminated languages, when we reach the point where it's easy to add slangs, an alternative would be to parse the VCard or XML as part of the main parse (that is, enter a grammar parsing XML up until the closing tag, then hand back to the main language). That would mean we're rid of any need for terminators and get to check it's valid XML or VCard or whatever along the way. |
@jnthn, to address your points: How does this not save on typing. I hate to say show your math, so let me show mine. Consider: To address your first point, consider:
b) With proposal:
I end up with difference of 0, without the redundant "VCARD". And the second: It is less likely to make mistakes, because in the event of cut and paste, you are copying text with the delimiter included. No possibility of mistakes, then. I do understand your willingness to prefer Slangs rather than a core addition, but how many Slangs will Raku need before a core addition is warranted? Thanks for your comments. |
I had that thought at first, too, but then realized @jnthn is right for the XML case: my $xml = q:thru!</root>!;
<root>
<section>
<item />
</section>
</root> vs my $xml = q:to!XML!;
<root>
<section>
<item />
</section>
</root>
XML The only difference is that the first adds |
Ah! Thanks for the clarification, @codesections. |
That is, even if I pick a reasonable terminator rather than being deliberately brief. I still type less characters by using the terminator form. Similarly:
This is a fair point.
Well, not that mistake. But if I paste a decent amount and the opener is off-screen I might forget that I need to copy-paste the final line of the data into
I guess in a sense my comment that slangs could be "an alternative" was not the best choice of words, in so far as this needn't be either-or; what you're proposing is a generic language feature, whereas slangs are inherently a specialized solution that, if available, would happen to also address what is wanted here. |
Thanks for your thorough explanation. My final reason for this discussion is to bring up the fact that since there is a q:to// in core, a q:thru// would be logically consitent and an alternative through with what already exists. I will still consider working on a PR for final consideration. Still trying to parse through Perl6/Grammar.nqp though. The rule is clearly marked, however I have still yet to understand it's complete functionality. Thanks for your time |
For such naturally terminated languages, when we reach the point where it's
easy to add slangs, an alternative would be to parse the VCard or XML as
part of the main parse (that is, enter a grammar parsing XML up until the
closing tag, then hand back to the main language). That would mean we're
rid of any need for terminators and get to check it's valid XML or VCard or
whatever along the way.
Like what I do with { use v5-linline; print qw(good old Perl) } blocks. A way
to do it with less black magic than
https://github.com/niner/Inline-Perl5/blob/master/lib/v5-inline.pm6 will be
appreciated :)
|
This seems like the proper entry point for a PR, however I don't see much in the way of a regex. Looks like I would have to trace where $*W.herestub_queue is sourced. |
Given that blocks of text with incusive ending delimeters are becoming more polular, why not allow Raku to use these natural ending delimiters in a heredoc?
Consider the VCard...
...and XML....
...HTML and others, it seems only natural that a Raku coder would do:
...and...
Would this be worth a consideration to add to the language spec?
Thanks to codesections on #raku for a better suggestion for the syntax.
The text was updated successfully, but these errors were encountered: