-
-
Notifications
You must be signed in to change notification settings - Fork 21.3k
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
GDScript: Add raw string literals (r-strings) #74995
Conversation
Code looks good to me. Implementation idk, I don't get if it's possible to have a raw string with both " and ' in it. Though I guess that's inherent to the concept.
I don't think there's a neat way to solve this without making the highlighter remember things between lines. It might be solved by an extra region paintover, as in getting the string delimiters and then getting all slices starting with |
Yes, you can combine quotes of different types.
I think we can think about this later, the highlighter has other issues related to newlines and not only. I think the main use case for r-strings is regular expressions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything looks good, but what's up with having a bunch of navigation-related files in the changed files? Did you add them by accident?
I don't see any navigation files in the changed files, what files are these? |
Oh I'm so sorry, I didn't realize I was looking at something else ;w; |
aee2def
to
e5f67cc
Compare
How it works? In regular string literals, you can use special characters ( r-string literals have the advantage that you get the same string that you see in the source code between For example, in the literal There is another type of raw string literals. R-strings in C++ or Nowdoc syntax in PHP. You can specify a sequence of characters that does not appear in a string, and terminate the literal with the same sequence (in PHP) or the reverse sequence (C++). R"(")"
// <<^>>
R"*()")*"
// <<<^^>>>
R"**()*")**"
// <<<<^^^>>>> But I don't think we need a solution as universal as C++ or PHP. String literals in GDScript are already very similar to Python, perhaps we should just copy them like we did in this PR? |
Why not both? Lowercase "r" would be the current implementation, and uppercase "R" would be the C++/PHP one? |
This is very rarely required, in my opinion. It is a more complex syntax, while GDScript is a simple language. I think that a language like GDScript should not have many different syntaxes for similar purposes, it can confuse users. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't check the code yet, but the GDScript team approve the PR.
There was a question about whether we should add regular expression literals, like in JavaScript. Answer: |
e5f67cc
to
2964c7d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved by the GDScript team, r-strings as presented, are a good addition to the language.
Thanks! |
Closes godotengine/godot-proposals#5362.