3 ms·
Interfaces are the most important thing Zig needs to implement ASAP It would also help creating a uniform standard library, for example creating a Writer inter
by remorses 4y ago
Interfaces are the most important thing Zig needs to implement ASAP
It would also help creating a uniform standard library, for example creating a Writer interface instead of having specific functions for files, sockets, buffers and all kind of types
- jimbob45 4y agoHow 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