3 ms·
I think the main thing is that it is all done in the type system at compile-time. This is the kind of thing C++ is good at but I’m not sure that C can do it wit
by jandrewrogers 2y ago
I think the main thing is that it is all done in the type system at compile-time. This is the kind of thing C++ is good at but I’m not sure that C can do it with the same guarantees.
- pjmlp 2y agoIt can't, because C doesn't have the ability to create library types as if they were built-ins.
- uecker 2y agoWhy would this be required?
- pjmlp 2y agoBecause otherwise there is no mechanism to introduce types, that can be used as built-is, while having the connection points across the language to enforce variants.
- uecker 2y agoWhat I do not get is the "can be used as built-in" part. What exactly does this mean? You can enforce invariants by encapsulating structures behind an API. This works fine in C (even better than in C++ IMHO).
- hgomersall 2y agoThe other thing that is important is the statically enforced move and ownership semantics. They are required for types to encode state.