V: 'let' syntax

Created on 8 Jul 2020  路  14Comments  路  Source: vlang/v

Reason

As writing ':=' is not very ergonomic to type, because both characters are typed with the pinky, I would propose an optional 'let' syntax like in Rust.

Example

let x = 5
Feature Request

Most helpful comment

The := syntax is not going to change. The linked article explains the benefits well.

All 14 comments

:= is shorthand for var name int. I don't think this will be done.

Oh, i didn't know about that, could you give an example on how to use var name int?

You can't use this but like Go := means the same thing as it goes against one way philosophy.

What about the c-like u8 x = 5?

You can do it like this x := u8(5) which is more simpler.

I dont think it is simpler because of the colon

The := syntax is not going to change. The linked article explains the benefits well.

and what is the big difference between x := 5 and let x = 5 that prevents it?
it is easier to type the let version tbh

@bashery let just introduces a new keyword and it is long to type as compared to x := 5.

but more ergonomic

(sorry if i'm annoying)

Ergonomic? How? It's still not going to change, but I'm wondering how it can be considered "ergonomic" if it requires more typing, which adds stress to the carpals, increasing the likelihood of carpal tunnel syndrome. That seems anti-ergonomic, to me.

@JalonSolov you don't have to use your pinky twice in a row on two keys which are relatively far apart from each other

So the amount of time is approximately the same, but the code is read a lot more than its typed (90/10), and x := 0 is a lot more concise and readable than let x = 0.

Especially mut x := 0 vs let mut x = 0

Was this page helpful?
0 / 5 - 0 ratings

Related issues

clpo13 picture clpo13  路  3Comments

jtkirkpatrick picture jtkirkpatrick  路  3Comments

PavelVozenilek picture PavelVozenilek  路  3Comments

shouji-kazuo picture shouji-kazuo  路  3Comments

penguindark picture penguindark  路  3Comments