News for hackers. Stuff that matters.
Re:Toward Go 2 by masklinn on Thursday July 13, 2017 @04:26PM (#14764854)
> I had thought enums can only be used as named types. Good to know they can hold data as well.

That depends on the language, and enums being sum types also depends on the language.

* Rust and Swift enums are sum types (they can hold data and every variant can hold different stuff), there is also a ton of (mostly functional) languages with sum types not called enum: Haskell, F#, OCaml, … there are also languages which replicate them via other structures (sealed classes in Kotlin, case classes in Scala).

* java enums (a bare "enum" is the C one) can hold data but every variant must hold data of the same type so you'd need up/down casts

* C++, C# and C enums can't hold data

Go does not have enums.

Re:Toward Go 2 by pjmlp on Friday July 14, 2017 @07:44AM (#14769044)
C++17 has support for sum types via std::variant.
Re:Toward Go 2 by matt_kantor on Friday July 14, 2017 @10:21AM (#14769985)
Minor nitpick: case classes in Scala are product types, not sum types. I think you meant "sealed traits".
Re:Toward Go 2 by masklinn on Friday July 14, 2017 @01:09PM (#14771347)
The combination of both really.