Replies: 7 comments
-
I think |
Beta Was this translation helpful? Give feedback.
-
The ones I've seen are
I don't think I've actually seen anyone using keyword identifiers unless it was done by |
Beta Was this translation helpful? Give feedback.
-
I like using r#keywords! Using another name is always at least slight less clear. It may be harder to r#type though, depending on the tooling. |
Beta Was this translation helpful? Give feedback.
-
I think |
Beta Was this translation helpful? Give feedback.
-
Compatibility across epochs/editions is definitely the reason raw keywords / While we theoretically could replace some aliases with raw keywords instead, aliases have been the only option for so long that they're the de facto standard, so we'd need a pretty strong motivation to switch. And personally, even if we could boil that ocean, I like aliases better for subjective aesthetic reasons and because they're fundamentally a simpler solution to this problem (grokking how raw keywords help with the cross-epoch lexing problem may not be that hard, but it's not trivial either). |
Beta Was this translation helpful? Give feedback.
-
Also recall how difficult it is to figure out hwo to use raw keywords in |
Beta Was this translation helpful? Give feedback.
-
I like |
Beta Was this translation helpful? Give feedback.
-
Rust supports a syntax called "keyword identifiers", where you may call a variable
r#type
instead of resorting to an alias likety
.However, it is also common to see (even in rust-src) that
type
is aliased asty
when used in variable names or struct fields.Should
r#type
orty
be prefrred? If the latter is preferred, what about other keywords? Is there a conventional mapping from the keyword to the alternative identifier?For example, in Java, it is common to have variables named
clazz
when the variable type is ajava.lang.Class
.It would be useful for provide such a mapping, or otherwise to encourage use of
r#
in api-guidelines (especially the naming section)Beta Was this translation helpful? Give feedback.
All reactions