I’m pretty sure that’s an interface union, not a sum type. That said, you could definitely do an option type using interfaces, but it would be less efficient than pointers directly because of the itab overhead.
> I’m pretty sure that’s an interface union, not a sum type.
It's a kind of sum type, but it can only be used to constrain types for a generic parameter.
That is, you can define `func foo[T StaticOptional[int]](x T)` and then call it as `foo(StaticNone{})` or `foo(StaticSome[int]{123})`, but you can't do `func foo() StaticOptional[int]` or even `func foo[T StaticOptional[int]]() T {return StaticNone{} }`.
It's a kind of sum type, but it can only be used to constrain types for a generic parameter.
That is, you can define `func foo[T StaticOptional[int]](x T)` and then call it as `foo(StaticNone{})` or `foo(StaticSome[int]{123})`, but you can't do `func foo() StaticOptional[int]` or even `func foo[T StaticOptional[int]]() T {return StaticNone{} }`.