-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Literal strings (without interpolation) #11567
Comments
While we're at it, I wouldn't mind macro u_str(s) UTF8String(s) end |
👍 to both ideas... |
Yes, I saw that post. More than one package came up with the same solution, which is why something in base is warranted. I one of my package (poyglot.jl), using inline Perl code is quite tedious due to that. I would avoid "R" if possible, even though it would feel familiar to python, since "r" is already used for regex. "l" for literal sounds good to me. On top of that, Although I see the point, could you elaborate with some examples on where u_str would be useful? |
I'd also like something that isn't totally raw, but doesn't do interpolation... |
You mean by parsing only backslash sequences? Should we call it "quoted" string? (q"")? " -> interpolated/backslash |
Yes, you've got it exactly! 👍 |
I can give a stab at this, should be pretty trivial. But some feedback from @StefanKarpinski @pao (from issue #5135, #5200) would be nice. IMHO we should keep prefixes to a minimum, but q/l seem pretty useful to me. I'm still not convinced about u for unicode (python went down that road already). Some arguments would be nice to hear. |
The C/C++ standard is: u8 for UTF-8, u for UTF-16, and U for UTF-32, and L for wchar_t (either UTF-16 or UTF-32). It might be nice if Julia had all of these, and maybe an a for ASCII (so that it could be checked to see if it really was just an ASCII string)... it would help interfacing with C a lot. |
(how'd I get involved, I was just acting as the collective unconcious!) But yeah, a true "do what I say, not what I mean" string literal macro seems almost reasonable to have. Problem: we don't have arbitrary string delimiters, so you still have to escape the |
I don't really need the "totally" raw format, but having a set of string macros compatible with the C/C++ definitions, without interpolation, that also would help type stability, I think would be useful. |
On 06/04/2015 05:43 PM, pao wrote:
Sorry :), you made pretty good points in other issues.
True, but if you have many of them, l""" would still be a pretty good I have mixed feelings about arbitrary delimiters (mostly on the negative |
I also dislike arbitrary delimiters... |
We can also have postfix flags, as in regexes http://julia.readthedocs.org/en/latest/manual/strings/#regular-expressions, to further set the string behavior... |
Relevant previous discussion: https://groups.google.com/d/topic/julia-users/956hxyU03hc/discussion |
I always found it really obscure to have lots of different string prefixes. It's hard to remember what they mean, and nearly impossible to guess. Some could be made quite clear, e.g. |
OK, I could live with I was really surprised when Stefan said that recently... my main beef with it is the syntax... I'd not be so unhappy with it if 1) it were limited to strings with a particular prefix, and 2) it used the syntax |
Don't get him started. Also, @JeffBezanson, I'm pretty sure you don't like multiline comments either. |
On 06/05/2015 05:36 AM, Scott P. Jones wrote:
I would be in favor for short identifiers, if these happen to be
I don't have anything in favor/contrary to $ or (). () would clash |
Multiline comments are nowhere near the problem that string interpolation is. There is no comparison. Code just doesn't belong in strings. |
On 06/04/2015 07:01 PM, Cristóvão Duarte Sousa wrote:
Maybe this could actually be a better place to specify internal encoding? l'str'u8 would request an utf8 literal? I actually like postfix flags better ... |
How did string interpolation ever get into the language, if you dislike it so much? Did the rest of the "Gang of Four" gang up on you? ☺ |
Luckily the |
closed by #19900 |
Am I wrong, or the is currently no way/macro in Base to enter a string without interpolation? I see
@b_str
,@r_str
and@v_str
.I would definitely add some standard macro for that. Maybe
@l_str
for literal?The text was updated successfully, but these errors were encountered: