|
|
|
|
|
by randomdata
1491 days ago
|
|
> but `iota` is also used for other purposes. According to the Go spec[1] iota exists specifically for enum generation. The closure of the enum is also defined. There is no other intended purpose. If a developer has found a new way to overload it in some new way they can equally do the same in C, so that is moot. Enums are not sum types in either language, with no expectation of behaving like sum types, there is no debate about that. They are simply enums. [1] https://go.dev/ref/spec#Iota |
|
This assertion is nowhere in the Go spec, not even implicitly.
`iota` is a convenience sequence generator, it is no more "specifically for enum generation" than sqlite's AUTOINCREMENT qualifier is. Or excel's cell-sequencing system.
Further demonstrating that the goal was not to replicate C enums, iota can not be advanced manually save by adding intermediate discarded case.
> If a developer has found a new way to overload it in some new way they can equally do the same in C
No, they can not, literally the second example of your link has to be written and maintained entirely by hand in C, to say nothing of the second example block.
> Enums are not sum types in either language, with no expectation of behaving like sum types, there is no debate about that. They are simply enums.
Go still does not have enums, and your generalised statements about enumerated types remain incorrect regardless of sum types.