4 ms·
How are you going to implement interfaces if Zig is without classes in the first place?
by jimbob45 4y ago
How are you going to implement interfaces if Zig is without classes in the first place?
- mirekrusin 4y agoGo has interfaces and doesn’t have classes.
- akira2501 4y agoThere's quite a bit of mildly hairy runtime code necessary to achieve this.
- anonymoushn 4y agoFor the equivalent thing (interfaces with runtime dispatch and without owning the underlying struct) Zig has explicit vtables. I sort of think any new "interfaces" feature should at least partly be about describing constraints on types at compile time.
- remorses 4y agoi think adding interfaces that are simply enforced at compile time would be a good start You could create a new type like Dynamic(InterfaceName) that handles dynamic dispatch somehow