hylo icon indicating copy to clipboard operation
hylo copied to clipboard

The "inconsistent" syntax between "+=" and "="

Open rayx opened this issue 2 years ago • 1 comments

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.

rayx avatar Aug 25 '22 04:08 rayx

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.

dabrahams avatar Aug 26 '22 02:08 dabrahams

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.

kyouko-taiga avatar Nov 01 '22 15:11 kyouko-taiga