5 ms·
In many cases you can get away with just using a struct with a tag (no unions). Yes, it wastes memory, and isn't as safe as a proper sum type, but at least it's
by tayistay 6y ago
In many cases you can get away with just using a struct with a tag (no unions). Yes, it wastes memory, and isn't as safe as a proper sum type, but at least it's memory-safe for C++ objects and you can use a normal switch statement. Compiler warns if your switch isn't exhaustive. Compile times are fast too.
- jcelerier 6y ago> In many cases you can get away with just using a struct with a tag (no unions). Yes, it wastes memory, so... it's a no-go ? if you don't care about wasting memory just use python or JS
- tayistay 6y agoObviously, there are various reasons why you can't "just use python or JS" for a particular project.