| ▲ | continuational 7 hours ago | |||||||||||||
Sure, but this is an example from the article, and pertains to sum types in general, not just Maybe. | ||||||||||||||
| ▲ | dnautics 7 hours ago | parent | next [-] | |||||||||||||
i dont think its generally a good idea to be making complex type generators like this in zig. just write the type out. the annoyingness of the thing you tried to do in zig is a feature. its a "don't do this, you will confuse the reader" signal. as for optional, its a pattern that is so common that it's worth having builtin optimizations, for example @sizeOf(*T) == @sizeOf(usize) but @sizeOf(?*T) != @sizeOf(?usize). if optional were a general sum type you wouldn't be able to make these optimizations easily without extra information | ||||||||||||||
| ||||||||||||||
| ▲ | 7 hours ago | parent | prev [-] | |||||||||||||
| [deleted] | ||||||||||||||