Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support multiple inheritance #64

Open
jrevels opened this issue Nov 3, 2022 · 3 comments
Open

support multiple inheritance #64

jrevels opened this issue Nov 3, 2022 · 3 comments

Comments

@jrevels
Copy link
Member

jrevels commented Nov 3, 2022

when authoring a new schema version, it is not uncommon to want to inherit the required fields of two or more unrelated (in lineage) schema versions

This should be quite feasible/straightforward in Legolas-land, as long as we:

  1. force the author to specify the order in which the multiple ancestors should be applied
  2. support new syntax for this in our schema version identifiers, which captures the aforementioned ordering
  3. have some basic type checking to ensure that overlapping required fields aren't mutually incompatible, i.e. later-applied parents' required fields must either be entirely disjoint with earlier parents' required fields, or be valid subtypes of them
@jrevels
Copy link
Member Author

jrevels commented Nov 14, 2022

Note that it's currently pretty trivial to evaluate a predicate across a given schema version's ancestry:

function has_matching_ancestor(predicate, sv::Legolas.SchemaVersion)
    predicate(sv) && return true
    p = Legolas.parent(sv)
    isnothing(p) && return false
    predicate(p) && return true
    return has_matching_ancestor(predicate, p)
end

If we implement this, stuff like this will turn into a tree walk, which is just complicated enough that it might be worth providing some utilities around

@jrevels
Copy link
Member Author

jrevels commented Jan 22, 2023

support new syntax for this in our schema version identifiers, which captures the aforementioned ordering

I think this should just be [<lineage>, <lineage>, ...]. Here's a (purposefully pretty complicated) example:

a > b > [c > d > [e,  f], g > [h, i > j], k > l > m] 

In Julia, the syntax would be:

@version FooV1 > [BarV1, BazV1] begin
    ....
end

@kleinschmidt
Copy link
Member

Need to make sure we do this in a non-breaking way, and develop good recommendations around how to use this new power for good rather than evil.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants