4 ms·
> Now, you are given an AInterface* object and want to know whether it has a certain guarantee or not. Eiffel guarantees this in the LSP sense, by enforcing th
by brandmeyer 7y ago
> Now, you are given an AInterface* object and want to know whether it has a certain guarantee or not.
Eiffel guarantees this in the LSP sense, by enforcing that overrides `require` as much or less than their base class, and `ensure` as much or more than their base class.
If you want to query that from AInterface alone, you should expose a virtual member that allows you to make the specific inquiry of interest from AInterface. In effect, if users of AInterface must know that only some AInterface's meet some guarantee, you must expose some knowledge of the guarantee in AInterface itself.
For example, AInterface can expose a boolean predicates like supports_foo, or it can return an object that is comparable with a std::strong_ordering.
- MauranKilom 7y agoI fully agree, this is what I would go for in this case. The only caveat is that this is duplicating information that RTTI already has available, i.e. space overhead. That's not a strong argument, but still a pareto-optimal niche.