Structural Typing in C!!! Finally done hammering on this damn thing. Fuck.
https://thephd.dev/_vendor/future_cxx/papers/C%20-%20_Record%20types.html
Fuck!!
Structural Typing in C!!! Finally done hammering on this damn thing. Fuck.
https://thephd.dev/_vendor/future_cxx/papers/C%20-%20_Record%20types.html
Fuck!!
@thephd Some thoughts from the maintainer of a small C implementation:
1. I think structural typing in C would be valuable.
@sheumann I don't really have any connotation for "extending a base type with more members" because that's just inheritance to my brain. You could make a version of composition where you can add a member to a structure and then give it a way to say "actually, all of my members are part of the thing you put me inside". That might give you the layout of composition but the "feel" of extension/inheritance that you're looking for.
When I write "anonymous" in my prose, I'm just referring to structures and unions without tags. The official standardese is very clear that we are not modifying the base algorithm: however you were comparing bitfields before, and however you were comparing anonymous unions/structures before, you keep doing that just with the strcmp for the names removed for _Record(types). For just _Record, the tag name at the top level is ignored, but everything else proceeds as normal.
I don't think I want regular attribute syntax, due to attributes being ignorable. This cannot be ignorable: it changes the way code is written, and changes a fundamental property (compatibility rules). I wouldn't mind discarding _Record(types) and _Record(vendor::stuff) to just keep the base one, though it should be known that doing so will cook usecases.
I'm glad you think structural typing is valuable! Hopefully we can make progress with something along the lines of _Record.