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

Introduce switch and void, remove condition #43

Merged
merged 3 commits into from
Aug 25, 2015

Conversation

roblabla
Copy link
Member

Switch is much more flexible, condition felt clunky and out of place.

the idea of switch is to mimic C's switch/case statement.

  • compareTo: The name of a field to be switched against.
  • fields: An object where the key is a possible value of field, and the value is the type to use in case the field matches the key.
  • default: Optional, if present, the type of what to read when field matched none of the values. If not present, the impl should error out as it means you have reached data outside the expected realm (values are expected to be exhaustive when default is not present).

void is also introduced. It is a type that does not read anything and returns null. It doesn't write anything and has a size of 0.

@rom1504
Copy link
Member

rom1504 commented Aug 24, 2015

transformation https://gist.github.com/roblabla/c1cdb842fd6a9e1f9978 (useful for 1.9)

rom1504 added a commit that referenced this pull request Aug 25, 2015
Introduce switch and void, remove condition
@rom1504 rom1504 merged commit a3c60d7 into PrismarineJS:1.8 Aug 25, 2015
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

Successfully merging this pull request may close these issues.

None yet

2 participants