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

enum tweaks #480

Closed
bernardnormier opened this issue Mar 4, 2023 · 1 comment
Closed

enum tweaks #480

bernardnormier opened this issue Mar 4, 2023 · 1 comment
Labels
Milestone

Comments

@bernardnormier
Copy link
Member

bernardnormier commented Mar 4, 2023

In light of #30 (comment), I propose to make a few tweaks to enums.

  1. An enum defined in an encoding = 2 file must have an underlying type.
    Rationale: we want to reserve the Slice2 encoding of enums (both checked and unchecked) without underlying type for the future enums-with-values.

  2. A checked or unchecked enum defined in an encoding = 1 file cannot have an underlying type (that's already the case today).
    Rationale: there is only one Slice1 encoding for enums and it would be confusing the add an optional underlying type with no effect on the Slice1 encoding.

  3. A checked or unchecked enum defined in an encoding = 1 file is mapped and encoded with Slice2 as if if had been defined in an encoding = 2 file with the varint32 underlying type. (Already the case today).

Rationale: language-mapping wise, that's the only reasonable behavior.

This means:

encoding = 1
unchecked enum Error { NotFound }

cannot carry "-1" when encoded with Slice1, but can when encoded with Slice2.

@InsertCreativityHere
Copy link
Member

This was implemented in #489.

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

No branches or pull requests

2 participants