sunjay / brain

A high level programming language that compiles into the brainfuck esoteric programming language

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Tagged Unions / Enums

sunjay opened this issue · comments

Needs #39 and optionally #40 before implementation.

Support tagged unions / enums with arbitrary nesting.

enum Foo {}

enum Bar {
    Foo(Foo),
    NotFoo,
    DefinitelyNotFoo {a: u8, b: u8},
}

enum Direction {
     North,
     East,
     South,
     West,
}
  • Size is of the largest variant + tag which is used to determine type
  • Accessing variants using paths Bar::NotFoo
  • Bring variants into the current namespace use Bar::*