Open rafaqz opened 8 months ago
I agree that inheriting interfaces is a key ingredient (see our recent Discourse discussion).
Note that it is already possible at the moment, simply by adding Interfaces.test
of the parent interface as a mandatory condition. So the key question is what we hope to achieve with a different syntax / implementation.
Yes its possible in the testing, but you don't get any traits to check that you passed it. The idea is that both tests and traits would be inherited automatically.
@gdalle I just realised having inheritance for options means we have to define the NamedTuple
of options inside the macro so we can get the keys to define abstract types for them. So your changes allowing us to move objects out of the macro wont be able to be used.
I'm kind of keen on that change, because hypothetically large interfaces could even span several code files
Sure, I guessed as much.
But: how do we get the NamedTuple
keys into the macro as an expression. We cant inspect a variable in a macro and we cant define types later at runtime.
(You may need to choose nice layout or iheritance... or just move individual option functions to files and make all your options single lines calling those functions)
If there's a choice I definitely go for inheritance.
Each optional component would (hidden in the macro) define the abstract type like:
We could make it nicer looking, but that's the direct translation from what we have now
First we can just inherit the main interface
But we could also inherit the optional component, which itself inherits the interface:
We would test the interface by iterating over
supertype
until we hitAbstractInterface
then working backwards, so the basal interface is tested first. When@@implements
has multiple options, we would take theunion
of the interfaces to test at each step to avoid duplicating any tests..But... what we really want is a hack for multiple inheritance:
Where we would drop the real inheritance and instead write something like:
Then all tests and trait queries would recurse over
inherits(T)
if a trait is false forT
.