Hi everyone,
Currently, string literals have type str/_; e.g. "foo" has type str/3.
This means that string literals are stored on the stack and are
constructed anew for every function invocation with a series of mov
instructions.
While this is very occasionally useful, and it mirrors how vectors work,
I suspect that 99% of string literals are actually intended to be stored
in constant memory. The current behavior is a burden and an aesthetic
problem, since in order to achieve the desired behavior, 99% of string
literals will need to be prefixed with & or ~; e.g. println(&"Hello world!")
I'd like to propose that unadorned string literals instead have the type
&static.str, which mirrors how it (usually) works in C and C++. To get
the current behavior one would write "Hello world"/_. This is slightly
inconsistent with vectors, but string literals are special anyway in C
and C++. This will make almost all the ~" punctuation-diphthongs that
are peppered throughout Rust code go away.
Thoughts?
Patrick
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev