3 ms·
That would take adding enums, which they aren't doing.
by monocasa 7y ago
That would take adding enums, which they aren't doing.
- akavi 7y agoFor anyone else who was confused: "enums" is what Rust calls sum types.
- stcredzero 7y agoenums/sum type functionality could be implemented using Interfaces in golang.
- akavi 7y agoNo, they can't. At least not in a type-safe way.
- stcredzero 7y agoJust define an Interface which includes the implementation of thisIsMySumTypeAsAnInterface() Then only types which implement that are in that Interface. There's your enum/sum type. Not ironclad, but safe enough to get things done.
- stouset 7y agoIt also doesn't actually accomplish what people are talking about using sum types for. There's also no language support for ensuring you've exhaustively matched every variant.