Uh oh!
There was an error while loading. Please reload this page.
RFC: ES6-style unicode string escaping. - #446
Conversation
edef1c
commented
Nov 6, 2014
👍 |
emberian
commented
Nov 6, 2014
👍 as well. |
blaenk
commented
Nov 6, 2014
Yeah this is nice. |
reem
commented
Nov 6, 2014
+1 from me too. Definitely an improvement. |
pnkfelix
commented
Nov 7, 2014
One drawback not mentioned in RFC: |
pnkfelix
commented
Nov 7, 2014
(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) |
SimonSapin
commented
Nov 7, 2014
@pnkfelix I don’t understand how |
alexcrichton
commented
Nov 7, 2014
I think @pnkfelix may be referring to something such as: format!("{foo} \u{AF} {bar}", foo = "", bar = "")In this case the braces around |
SimonSapin
commented
Nov 7, 2014
Oh, I see. That’s a good point, I’ve added it to Drawbacks. |
65cd08b to
b310c87CompareGankra
commented
Nov 7, 2014
Is it possible to just use parens or some other delimiter? |
ftxqxd
commented
Nov 7, 2014
👍; this makes Unicode escapes much clearer and more obvious. It should be noted that using |
mdinger
commented
Nov 8, 2014
As best I can tell, the aliases used with Python Unicode escape sequences are documented here |
huonw
commented
Nov 8, 2014
@P1start (FWIW, I actually have a macro lib that offers that.) |
SimonSapin
commented
Nov 8, 2014
@gankro, it would be possible, but we would lose the benefit of the ES6 precedent. @P1start, interesting. |
pnkfelix
commented
Nov 25, 2014
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? |
SimonSapin
commented
Nov 25, 2014
@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? |
pnkfelix
commented
Nov 25, 2014
@SimonSapin i suspect warning would be best. |
SimonSapin
commented
Dec 10, 2014
@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? |
pnkfelix
commented
Dec 10, 2014
@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