Comment by lelanthran
16 days ago
How do you expect to use sum types in assembly? Remember where C came from and why it was designed the way it was.
16 days ago
How do you expect to use sum types in assembly? Remember where C came from and why it was designed the way it was.
A naive sum type is just a tag plus a payload. There is no problem here. If you have enums you could have had sum types.
The historical argument and appeal to assembly is illogical here. The only real argument is that niche value optimization is too complex or too clever for the time so even if sum types were in C, nullable pointers would still exist either way.
I remember why C stayed what it is at least: elitism and gatekeeping. And YAGNI, repeated millions of times, of which only the first few were correct.
You're telling me OCaml / Rust / Haskell compile to fairy pixie dust? Obviously their compilers figured it out and it works.
> I remember why C stayed what it is at least: elitism and gatekeeping.
If that was the goal, it failed horribly - the gatekeeping didn't work because the popularity exploded.
> You're telling me OCaml / Rust / Haskell compile to fairy pixie dust? Obviously their compilers figured it out and it works.
I said nothing of the sort.
You asked how sum types work in assembly. I'm telling you that at least 3 compilers figured that part out.
8 replies →