I've previously formed an arena of meanings used for representing the semantics in a language.
Typically, the arena allocates and holds strong references to these meanings, and the abstract meaning data type holds a weak reference to a meaning: whenever operational methods are called upon it, an upgrade is performed to decompose a copy of a fragment of the meaning's data.
There are several meaning variants and subvariants of variants with inherited operational data and methods.
The meaning data type is, therefore, large, and includes several methods that work in a number of variants such as is_foo_meaning()
and name()
.
In this scenario, I think it's more organized to have a limited form of inheritance in a single source file. I've thought of building a macro for this, but it's complicated because I need mainly:
- Overriding (dynamic dispatches are hard)
I might need:
super.m()
These I believe are easy:
- Test for variant (
meaning.is::<FooMeaning>()
).
Is there a crate for facilitating this, or should I stick to my manual approach?