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

Union types #118

Closed
4 tasks
brendanzab opened this issue Oct 29, 2018 · 3 comments
Closed
4 tasks

Union types #118

brendanzab opened this issue Oct 29, 2018 · 3 comments
Labels
A-type-system C-feature obsolete Cleaning up the backlog on 2020-10-09.

Comments

@brendanzab
Copy link
Member

brendanzab commented Oct 29, 2018

OpenType has lots of union types! We should have a nice way of describing them.

TODO

  • Add concrete syntax
  • Use backtracking and ordered choice
  • Identify common prefixes, without backtracking
  • Compile to tagged union types in the host language
@brendanzab
Copy link
Member Author

I wonder if we could have something like this:

union Foo (param : T) & Bar param {
    Foo0,
    Foo1,
};

This would ensure that each variant properly intersects with the given prefix.

@brendanzab
Copy link
Member Author

Perhaps this might be clearer:

union Foo & FooUnknown {
    Foo0,
    Foo1,
    FooUnknown,
};

struct Foo0 {
    version : U16Be == 0,
    data : U32Be,
};

struct Foo0 {
    version : U16Be == 1,
    data : F64Be,
};

struct FooUnknown {
    version : U16Be,
};

@brendanzab
Copy link
Member Author

I dunno though 🤷‍♂️

@toothbrush toothbrush added the obsolete Cleaning up the backlog on 2020-10-09. label Oct 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-type-system C-feature obsolete Cleaning up the backlog on 2020-10-09.
Projects
None yet
Development

No branches or pull requests

2 participants