Hi everyone,
So we still have a problem with reserved word/module name collisions,
even with separate namespaces. We have modules named "_str" and "_vec"
to avoid conflicting with the reserved words "str" and "vec".
Here are some possible solutions:
(1) Live with it. Use leading "_" for modules like _str and _vec.
("_vec" may end up ceasing to be a reserved word, but "str" is likely to
still a problem.)
(2) Rename the module "_str" to "string", similar to the way we named
what would probably have been "middle::type" "middle::ty".
(3) Make built-in types no longer reserved words, but instead special
identifiers that are always in scope and can't be qualified with module
names.
(4) Have the lexer lex "std::vec" together as one identifier. Have
"::foo" be equivalent to "foo", so that the user can say "::vec" in the
rare cases that that isn't enough.
(5) Add productions to the grammar for reserved words in the right
positions; e.g. (BNF):
import ::== "import" module-part ("::" module-part)* ";"
module-part ::== identifier | module-keyword
module-keyword ::== "str" | "vec" | "int" | "uint" | ...
There are probably other ways to finesse the problem.
I lean toward (3), and, failing that, (5), but I'm not particularly in
favor of one solution or the other (although I'd prefer not to do (1); I
think _str is universally disliked). Mostly I just wanted to throw some
ideas out there.
Patrick
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev