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

Enumerations #131

Closed
brendanzab opened this issue Nov 12, 2018 · 1 comment
Closed

Enumerations #131

brendanzab opened this issue Nov 12, 2018 · 1 comment
Labels
A-type-system C-feature obsolete Cleaning up the backlog on 2020-10-09.

Comments

@brendanzab
Copy link
Member

brendanzab commented Nov 12, 2018

Add some form of enumerations to the DDL. These are a set of grouped constants that may or may not be used for flags.

@brendanzab
Copy link
Member Author

brendanzab commented May 25, 2020

Thinking we could have an enumeration type like so:

ByteOrder : Type = enum {
    little,
    big,
};

This is sort of like a 'labelled' syntax over 'finite sets', as I tracked down in this twitter thread.

We'd also have a corresponding Format constructor:

ByteOrderFormat : Format = format enum U8 {
    little = 0x4949,
    big = 0x4d4d,
};

Where repr ByteOrderFormat is equal to ByteOrder

We could use this for defining unions:

Exif = format struct {
    byte_order : ByteOrderFormat,
    body : match byte_order {
        little => ...,
        big => ...,
    },
};

This would nicely solve both #15 and #118 as well.

@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