hylo
hylo copied to clipboard
The "inconsistent" syntax between "+=" and "="
This is a not an issue but a comment. As a user I find it confusing to require "&" in +=
, but not in =
. See the code below (I haven't been able to compile Val to verify the code, but from my understanding it's valid).
public fun main() {
var length = 1
length = 2
&length += 2
}
I understand the difference is because =
is not a function. But since both mutates value, I would expect they have the same syntax. Otherwise I'd have to stop to think if it's a =
or a function
when writing the code above. Also, since the language emphasizes mutable value, it would be great if it has a consistent syntax to help user to identify the places where a value is mutated. Just my thoughts, and feel free to close it if you don't agree.
You've got a point there! I think it's worth experimenting with both options. I agree it's hard to justify this inconsistency. We started where Swift was, and in that configuration it made more sense.
The point has been duly noted.
I will close this issue. Feel free to open a discussion over there if anything needs to be added.