bonobo-lang / bonobo

Strongly-typed, safe, opinionated systems language that compiles to C.
https://bonobo-lang.github.io
Apache License 2.0
14 stars 1 forks source link

Enum types #54

Open thosakwe opened 6 years ago

thosakwe commented 6 years ago

Enums by themselves would be anonymous. Typedefs would be used to provide access to these. To access specific fields, use the :: symbol.

type PromiseState = enum { pending, fulfilled, errored }
type Promise<T> = { state: PromiseState, value: T? }

fn doSomethingAsync<T>(value: T): Promise<T> => { value, state: PromiseState::fulfilled }
tejainece commented 6 years ago

Could this be a more compact syntax:

enum PromiseStat { pending, fulfilled, errored }
thosakwe commented 6 years ago

That could definitely be doable, and wouldn’t be that hard to parse.

My only concern is consistency. Since all other types are declared with “type foo”, I think it would be smart to also declare enums in the same way.

thosakwe commented 6 years ago

Remaining: