4 ms·
> Statically dispatched type object model using a newtype wrapper and Rust's declarative macros. Ok, what that means is that I have a MetaObject trait that I ca
by celeritascelery 4y ago
> Statically dispatched type object model using a newtype wrapper and Rust's declarative macros. Ok, what that means is that I have a MetaObject trait that I can use to easily add new data types and define the behavior for specific types.
If I understand correctly, this approach is try and address the expression problem[1]. It makes it easier to define new types for `Variant` (everything is defined in one impl block) at the cost of making it harder to add new `MetaObject` functions (you need to update every applicable impl block).
Also static dispatch seems like the wrong word here, because you are still doing runtime dispatch on `Variant`, even if not using `dyn` Objects. Static dispatch typically refers to monomorphization.
[1]https://craftinginterpreters.com/representing-code.html#the-expression-problem https://craftinginterpreters.com/representing-code.html#the-...
- harpiaharpyja 4y agoMy bad about the incorrect terminology. I figured if it's not dynamic dispatch it must be static but I probably should have done my homework before writing up a description.