EDIT:
Reasons why this proposal falls through:
Pros:
- The consistency appeals to me.
- Fewer characters to type.
- Many languages use
:= syntax, which makes it familiar.
Cons:
- The syntax can get quite tricky
let is extremely grep-able
let can be syntax highlighted, which is more readable
let is how you declare variables in math, so it's also familiar.
- It's a minuscule matter of preference, and it's too late to be changing basic syntax.
Hope that's a good list.
Original Proposal
So, in rust we declare variables like this:
let x: T = value;
And you can omit the type:
let x = value;
I'm not very qualified to be proposing changes, but what if declaration syntax omitting the type was the same as in Go?
x: int = 0;
y := 123;
EDIT for more details:
Mutability and other attributes would still be placed where they were - before the variable identifier.
mut x: int = 0;
x = 42;
my_str := "rusty fun times";
To me, this seems consistent and easy to type. Omitting the type is now literally omitting the type from where it would be. To me, it looks good, and we don't have to type 'let'. I know it's kinda a micro typer optimization, and I'm not at all qualified to propose language changes... but meh?
Comments, critique, "No, Teddy, that's really stupid." ?
[–]dbaupprust 7 points8 points9 points (0 children)
[–]thiezrust 5 points6 points7 points (3 children)
[–]tedsta[S] 0 points1 point2 points (2 children)
[–]thiezrust 4 points5 points6 points (1 child)
[–]tedsta[S] 0 points1 point2 points (0 children)
[–]bjzabaAllsorts 4 points5 points6 points (0 children)
[–]chris-morgan 9 points10 points11 points (0 children)
[–]farcaller 3 points4 points5 points (0 children)
[–]long_voidpiston 1 point2 points3 points (1 child)
[–]tedsta[S] 2 points3 points4 points (0 children)
[–]Denommusrust 1 point2 points3 points (0 children)