rafaqz / Interfaces.jl

Macros to define and implement interfaces, to ensure they are checked and correct.
MIT License
72 stars 4 forks source link

Add optinal component grouping #30

Closed rafaqz closed 8 months ago

rafaqz commented 8 months ago

Often optional components come in loose groups, like mutating functions push!, delete!, empty! would often all be implemented for a mutable AbstractSet.

it would be good to be able to specify this group with just mutable, and get the tests and traits for all its components.

Nested NamedTuple is one simple way to do it - but it loses the posibility to have components in multiple overlapping groups. adding a groups object after optional may be better design. It would be a NamedTuple of tuples of Symbol.

gdalle commented 8 months ago

While I understand the purpose, in the spirit of simplicity I don't really like the idea of a groups named tuple key. I think the person defining the interface can handle overlapping groups themselves, by concatenating named tuples.

gdalle commented 8 months ago

OK I'm starting to see what you mean as I take a look at #27

Maybe if we had inheritance we could use that instead of groups? As in, ArrayInterface could inherit from ArrayModifyInterface and ArrayQueryInterface?

rafaqz commented 8 months ago

Yeah this comes from the Set interface. And yes inheritance could really solve a bunch of this. I'll actually close this in favor of #33