4 ms·
Rather than traits like what Rust has, the approaches I've generally seen for polymorphic behavior are explicit "interface" structs that hold a vtable, or compt
by skribanto 4y ago
Rather than traits like what Rust has, the approaches I've generally seen for polymorphic behavior are explicit "interface" structs that hold a vtable, or comptime "duck-typing". I'm still rather new to Zig so there may be other approaches, but this is what I have seen so far.
One positive side effect is that there is only one "language" to learn as opposed to two different syntaxes like Rust does. While most people only use a very constrained part of the Rust type system, at the end of the day it is Turing Complete[1] (or possibly close to it? I don't know enough theory to know the rigor of what constitutes Turing completeness) and trying to keep all of it in mind can be taxing.[2]
[1]: https://sdleffler.github.io/RustTypeSystemTuringComplete/ https://sdleffler.github.io/RustTypeSystemTuringComplete/
[2]: https://hirrolot.github.io/posts/why-static-languages-suffer-from-complexity https://hirrolot.github.io/posts/why-static-languages-suffer...