-
Notifications
You must be signed in to change notification settings - Fork 5
-
Notifications
You must be signed in to change notification settings - Fork 5
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
String.rare: a half-cooked idea #13
Comments
While obviously |
I think the general problem is how to write any arbitrary text in the language, include backtick and But I think |
@hax I'm sorry, I'm not clear on your position. You said it's too much cognitive burden to have a method that serves this use case, but then you said that what is really needed is some way of solving this use case. Do you see some even simpler way of solving this problem? |
@conartist6 I mean, the real problem and requirements is not escaping or substitutions of selected special chars, but how to express those chars literally. So I wrote a proposal to solve the real issue behind that and will present it to the committee in Feb meeting. https://github.com/hax/proposal-raw-string-literals |
There's a pretty important difference between what you are and aren't escaping. I think if the embedding layer (raw-string) assigns some meaning to a character (like |
Your solution is essentially to allow users to choose which embedding holes they want to have in their raw string. Mine is just to define a method that does not need to have any embedding holes. |
I understand Note: u actually don't need to escape |
It's a bit funky though because you can write a literal |
@conartist6 Not sure what u mean. U can use |
Oh right, I forgot. |
I think there might actually be three functions worth considering:
String.raw
, as exists already does no processing of escapesString.cooked
, as proposed here processes valid javascript escapesString.rare
, which processes some escapes:\`
,\\
, and\${
The reason you want to process
\`
,\\
, and\${
even if you don't process any other escapes is that these three escapes always have meaning in a template string. Because they always have meaning, they create "embedding holes" in the language inside the template string: certain string content which has no valid syntactic representation.The most obviously difficult example is trying to write a template string inside itself:
if you had used
String.raw
then embedded content would be the unparseable:The text was updated successfully, but these errors were encountered: