Skip to content
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

Use of string concatenation rather than variable interpolation? #60

Open
con-mo8 opened this issue May 7, 2016 · 11 comments
Open

Use of string concatenation rather than variable interpolation? #60

con-mo8 opened this issue May 7, 2016 · 11 comments

Comments

@con-mo8
Copy link

con-mo8 commented May 7, 2016

One of the core advantages of Perl 6 over Perl 5 for me is how advanced variable interpolation is in quoting. For some reason most of perl6intro prefers "" ~ value ~ "" which I find kind of messy. Is there a strong preference for this? Or am I ok to go through and change these where appropriate? For example say "The capital of France is: %capitals<France>" works perfectly well. More complex expressions I'd prefer "{ expression }" to "" ~ expression ~ "". I'd reserve ~ for something more like $str1 ~ $str2 where there is no default quote construct to be included.

@hankache
Copy link
Owner

hankache commented May 8, 2016

@con-mo8 No specific preference.
In absolute, interpolation is better than string concatenation. So I prefer this: say "The zoo contains {@animals.elems} animals"; over this: say "The zoo contains " ~ @animals.elems ~ " animals";
Unfortunately the syntax highlighter (pygments) doesn't highlight correctly when interpolating code inside a string; the code inside {} will appear as raw text (font and color).
This is mainly why I used string concatenation. I want the readers to be able to grep visually the text part (string) and the code part.

@MadcapJake
Copy link

Though I definitely understand the concern for proper highlighting, I also wanted to add that technically in the example you gave @hankache you don't even need curlies as a simple () would inform the compiler that the prior word was a method call e.g., "The zoo contains @animals.elems() animals".

That being said, even my perl6fe language highlighter doesn't catch this style of interpolation (though it is planned).

@con-mo8
Copy link
Author

con-mo8 commented May 9, 2016

@hankache not sure it helps but the latest vim highlighter does fully support string interpolation amongst other more Perl 6 specific syntax.

@hankache
Copy link
Owner

@con-mo8 Unfortunately, asciidoctor supports only pygments and highlight.js. In addition pygments is the only one that does support Perl 6 highlighting.
@MadcapJake Were you considering adding Perl 6 support to highlight.js?

@MadcapJake
Copy link

@hankache unfortunately highlight.js doesn't support heredocs but otherwise I'm almost finished with Perl 6 support for it. I've been looking at SyntaxHighlighter which utilizes XRegexp and that has the ability to do named captures (for supporting heredocs) so I will probably do a plugin for that next.

Another option is GitHub's Highlights as that way you could directly utilize my language-perl6fe grammar, but I don't know how easy that would be to integrate into asciidoctor, I did a cursory look and I don't think anyone's tried it before.

@MadcapJake
Copy link

A final option would be to beef up Pygments' Perl 6 lexer! I'll take a look and see what can be done there too as I've written a Pygments lexer before.

@hankache
Copy link
Owner

@MadcapJake++

@hankache
Copy link
Owner

@MadcapJake Please do tell me if you manage to do one of the above, so I can test them on perl6intro.

@hankache
Copy link
Owner

@samcv is doing a great job on https://github.com/perl6/atom-language-perl6
Does anyone have any idea if we can let asciidoctor use https://github.com/atom/highlights ?

@samcv
Copy link

samcv commented Dec 26, 2016

@hankache you probably know I converted the docs site to use highlights, so it may be possible.
I don't know too much about asciidoc, what do we currently use for highlighting?

@hankache
Copy link
Owner

@samcv pygments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants