-
Notifications
You must be signed in to change notification settings - Fork 17.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
spec: clarify meaning of alias decls in sequence of "enum" const declaration #17784
Comments
CL https://golang.org/cl/32597 mentions this issue. |
Currently the spec says iota's value increments after each ConstSpec, and AliasSpec is disjoint from ConstSpec. So I think replacing "d" with "d = iota" would logically assign 2 to d, under the current wording. That said, if we did want to change it to increment at semicolons, I'm not opposed to that. I just expect in practice it won't really matter. If we choose to increment only after ConstSpecs, users can still include blank ConstSpecs next to AliasSpecs to increment iota; conversely, they can move AliasSpecs out-of-line to prevent them from incrementing iota. |
I agree with Matthew that the current interpretation is clear, and that it matters little in practice. I also think the current interpretation is defensible: iota shouldn't increment after an alias declaration that can't possibly use it. |
@mdempsky, @alandonovan Good point - with the current spec, incrementing iota with each ConstSpec is the same as incrementing with each semicolon... There's a simpler solution: Do not alias const aliases in the first place. Just something to keep in mind. |
If you replace 0 1 3.141592653589793 3.141592653589793 ( https://play.golang.org/p/4xOWo5vx8P ) Since => and = are essentially the same for consts, I'd expect them to behave identically. |
Locking because aliases are no longer proposed. |
prints
It probably shouldn't be allowed in the first place. Certainly the output is wrong (iota should be incremented with each semicolon).
The text was updated successfully, but these errors were encountered: