7 ms·
Thank you for distinguishing bindings and assignments. Please consider `var y := x * x` for consistency (note the ':=').
by lysium 13y ago
Thank you for distinguishing bindings and assignments.
Please consider `var y := x * x` for consistency (note the ':=').
- skrishnamurthi 13y agoWe considered it and decided against it for a few reasons. - We want := to mean "change". The initial binding is not a change. This is precisely the "bindings and assignments" distinction you're talking about. - A variable may in fact not be mutated. - A small point is that we want to localize editing when making a change. So, the way I read var y = x * x is, "y is currently bound to x * x. However, y is a variable, so this binding is not guaranteed to last. Be careful about assuming you know the value of y." If you then see y := x * z it reads as "y's value changes to that of x * z". So: "=" means "introduced a name with this value"; "var" means "but this binding may change"; ":=" means "and yup, it really _did_ change".
- skrishnamurthi 13y agoWe considered it and decided against it for a few reasons. - We want := to mean "change". The initial binding is not a change. This is precisely the "bindings and assignments" distinction you're talking about. - A variable may in fact not be mutated. - A small point is that we want to localize editing when making a change. So, the way I read var y = x * x is, "y is currently bound to x * x. However, y is a variable, so this binding is not guaranteed to last. Be careful about assuming you know the value of y." If you then see y := x * z it reads as "y's value changes to that of x * z". So: "=" means "introduced a name with this value"; "var" means "but this binding may change"; ":=" means "and yup, it really _did_ change".
- skrishnamurthi 13y agoWe considered it and decided against it for a few reasons. - We want := to mean "change". The initial binding is not a change. This is precisely the "bindings and assignments" distinction you're talking about. - A variable may in fact not be mutated. - A small point is that we want to localize editing when making a change. So, the way I read var y = x * x is, "y is currently bound to x * x. However, y is a variable, so this binding is not guaranteed to last. Be careful about assuming you know the value of y." If you then see y := x * z it reads as "y's value changes to that of x * z". So: "=" means "introduced a name with this value"; "var" means "but this binding may change"; ":=" means "and yup, it really _did_ change".