Bikeshed wheeee! The connotations/meanings I associate to these words are:
const => constant, doesn't change / can't be changed static => statically known (usually "without running it", like in static types vs. dynamic types, static analysis, etc.) The desired meaning here seems to be "statically allocated". So I would go with static. Close enough! The equivalent in Rust for const as above is basically "not mut". As long as globals were forced to be immutable (constant) the two meanings overlapped, so there wasn't any glaring problem (maybe some subtle redundancy), but once you let them be mut the conflict is obvious. On Tue, Mar 12, 2013 at 8:44 PM, Graydon Hoare <[email protected]> wrote: > Hi, > > At today's meeting we had a a discussion about two issues that > intersect, oddly, at a particular point of the syntax. The two issues are: > > - Removing the 'static lifetime-name -- currently used to denote > the lifetime of consts -- since the only other use of the word > (static fn ...) is going away when we finish with explicit-self; > renaming it (probably) to 'const since that's the word used to > introduce consts! > > - Adding mutable globals (unsafe-to-access, but needed in some > corner cases for mutexes and such). This is an old bug > (two years! https://github.com/mozilla/rust/issues/553 ) that > we've long assumed we'd have to implement eventually. > > We agreed to do the former (rename 'static to 'const) and collapse all > uses of the word "const" to mean this "read-only-memory" thing. But then > when pushing around possible syntaxes for mutable globals, such as the > following not-so-charming options: > > let mut x : T = v; // like in functions, but different since > the RHS must be a const and can refer to > values declared-after it. > > const mut x : T = v; // adding a modifier to 'const' but one that > reads somewhat absurdly: "constant mutable"? > > unsafe mut x : T = v; // more random choices... > > We stumbled on the _opposite_ possibility for const-vs-static: maybe we > should be retiring the "const" keyword and standardizing on "static", > for both mutable and immutable. The following cases would then fall out: > > static x : T = v; // constant init, immutable, like const today > > static mut x : T = v; // constant init, mutable, unsafe to access > > With values in that scope having 'static lifetime, and the word "const" > no longer appearing anywhere in the language. > > There are other options, probably, that we did not consider. Some people > suggested putting "global" in there instead of "static". Some suggested > going back to "var" rather than "let". > > This is an intentional (brief) request for a little syntax > bikeshed-discussion to see if anything else occurs to anyone, or if > anyone has strong reactions / preferences / thoughts to any of the above > options. We recognize that this does not _exactly_ align with the > meanings of the highly-overloaded words "const" or "static" in C/C++, > but think that there's some keyword and concept overlap here that can > probably be minimized. > > (Maybe reply for only a couple days and we'll summarize opinions and > pick something thereafter. No need for it to drag on forever.) > > Thanks, > > -Graydon > _______________________________________________ > Rust-dev mailing list > [email protected] > https://mail.mozilla.org/listinfo/rust-dev > -- Your ship was destroyed in a monadic eruption.
_______________________________________________ Rust-dev mailing list [email protected] https://mail.mozilla.org/listinfo/rust-dev
