Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFC: Better/Shorter syntax to declare multiple variables #64602

Closed
abbychau opened this issue Sep 19, 2019 · 2 comments
Closed

RFC: Better/Shorter syntax to declare multiple variables #64602

abbychau opened this issue Sep 19, 2019 · 2 comments
Labels
needs-rfc This change is large or controversial enough that it should have an RFC accepted before doing it.

Comments

@abbychau
Copy link

abbychau commented Sep 19, 2019

When we have multiple variable to be declared, we need to write something like this:

let (mut a, mut b, mut c, mut d) = (false, false, false, false);

There are two obvious factorizations:

The first part is to factorize the mut decorator, so to be let mut (a, b, c, d).
Another part is to spread the value tuple, so to be false.

That

let mut (a,b,c,d) = false;

is short while intuitive.


Last, in the long form

let (mut a, mut b, mut c, mut d) : (bool, bool, bool, bool) = (false, false, false, false);

if the type is required there, then it is able to be shorted to.

let mut (a, b, c, d) : bool = false;

I have thought of making bool and false there a bit more obvious like the JS style spread(not really the spreading meaning here though):
(false..) and (bool..) or using other notations like x!(bool) and [bool], and etc., but I think that keeping the simple form is good enough and because it does not seem to induce much misleadings while reading .

@memoryruins
Copy link
Contributor

For mut shorthand, there is a previous rfc and discussion in rust-lang/rfcs#2401

@jonas-schievink jonas-schievink added the needs-rfc This change is large or controversial enough that it should have an RFC accepted before doing it. label Sep 19, 2019
@jonas-schievink
Copy link
Contributor

Hi! Large additions to the language or standard library need to go through our RFC process. Before an RFC is written, the feature can also be discussed in our internals forum to find other people interested in it.

Closing in favor of an RFC.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-rfc This change is large or controversial enough that it should have an RFC accepted before doing it.
Projects
None yet
Development

No branches or pull requests

3 participants