-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
RFC: ES6-style unicode string escaping. #446
Conversation
👍 |
👍 as well. |
Yeah this is nice. |
+1 from me too. Definitely an improvement. |
One drawback not mentioned in RFC: |
(Well, what I said isn't actually quite right, since the Unicode escape is probably handled at an earlier lexical level and thus would not be seen by the fmt code) |
@pnkfelix I don’t understand how |
I think @pnkfelix may be referring to something such as: format!("{foo} \u{AF} {bar}", foo = "", bar = "") In this case the braces around |
Oh, I see. That’s a good point, I’ve added it to Drawbacks. |
65cd08b
to
b310c87
Compare
Is it possible to just use parens or some other delimiter? |
👍; this makes Unicode escapes much clearer and more obvious. It should be noted that using |
As best I can tell, the aliases used with Python Unicode escape sequences are documented here |
@P1start (FWIW, I actually have a macro lib that offers that.) |
@gankro, it would be possible, but we would lose the benefit of the ES6 precedent. @P1start, interesting. |
we decided in the meeting today to merge this. However, we also want to revise the RFC language to ensure up front that we will land this in a manner such that there would exist a window of time where the old syntax is supported; i.e.: First add the new syntax as a feature, convert our code to use it, let that settle, and then remove the old syntax. (Part of the reason we want to follow the above procedure is that we do not want to block 1.0 on this feature; making sure we remove the old syntax last, potentially in a separate beta cycle, should help mitigate that risk.) @SimonSapin would you be up for revising the text to accommodate the above goal, or would you like me to do it on your behalf? |
@pnkfelix Please do the revising, as I’m not sure of the details of the language you have in mind. Should usage of the old syntax give a warning, after the new one is added? |
@SimonSapin i suspect warning would be best. |
@pnkfelix The first part of this has landed: rust-lang/rust#19480 Should this be merged despite the "deployment plan" not being in the text? |
@SimonSapin ah sorry, I will try to merge pronto. |
In Rust, it's recommended to use short (non-zero-padded) code-points inside ES6-style escaping sequences (`\u{...}`), as it reduces the length of the literal, and works better on the eyes for average use cases, while mechanical parsing remains still fairly easy. See examples in the Rust RFC and related discussion: * https://github.com/rust-lang/rfcs/blob/master/text/0446-es6-unicode-escapes.md * rust-lang/rfcs#446 * rust-lang/rust#19739
Rendered.
Remove \u203D and \U0001F4A9 unicode string escapes, and add ECMAScript 6-style \u{1F4A9} escapes instead.
Text: https://github.com/rust-lang/rfcs/blob/master/text/0446-es6-unicode-escapes.md
RFC PR: #446