On 'static' vs 'global':
- 'static' would feel more familiar for C/C++ people, but is also way to overloaded there. - 'global' would be more unfamiliar, but also concise: 'This thing has global scope or lifetime'.

One thing I don't like about 'static' and 'global' is that they are longer and harder to pronounce compared to 'const' (by not much, granted).

So how about 'glob' ?
I like 'static' more than 'global' or 'const' for lifetime names, and
I agree that const and static should be unified into a single name.

'static' scares me a bit because of C's use of it in several somewhat
unrelated contexts, and so the name feels a bit polluted in my mind.

But I still like it best.

On Tue, Mar 12, 2013 at 5:13 PM, Benjamin Striegel
<[email protected]>  wrote:
I'll speak up in favor of ditching both "const" and "static" for "global".

     global foo: int = 1;
     global mut bar: int = 1;
     &'global baz

(Though not sure exactly what the 'static region is, does that last one make
sense?)


On Tue, Mar 12, 2013 at 3: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


_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to