3 ms·
In Rust, traits can be used via a vtable, but also (and the vast majority of the time) as regular old statically dispatched functions. That doesn't mean Zig co
by steveklabnik 3y ago
In Rust, traits can be used via a vtable, but also (and the vast majority of the time) as regular old statically dispatched functions.
That doesn't mean Zig couldn't do something similar if they want to, just pointing out that it's not always the case that it means dynamic dispatch.
- zozbot234 3y agoI didn't mention run-time dynamic dispatch, only a function dictionary (which C++ calls a vtable). Using traits for bounded subtype polymorphism is much like having a dictionary of functions that can be resolved completely at compile time, making it possible to use monomorphization and static dispatch.
- steveklabnik 3y agoOkay. It's clear we're using some words in very different ways (this is not subtype polymorphism in Rust either) but I see what you're getting at.