Get the latest tech news

Zig Interface Revisited


Achieving polymorphism via dynamic dispatch in Zig

This also enforces parameter checking at compile time to ensure the implementation’s functions match up to the interface’s ones. Some indirection: Dynamic dispatch requires extra function pointer calls (minimal, but real). With vtable interfaces, you can achieve dynamic dispatch, support uniform types, and write expressive, decoupled APIs.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of Zig Interface

Zig Interface