flax-lang/flax

Lack of union types

philpax opened this issue · 3 comments

Unsure if this is intentional or not, but there doesn't seem to be any facility for creating unions in the language spec (from the website) or in the compiler.

I posit this is useful, because:

  1. A systems language should have unions, as storing values of different types in the same memory space is important for efficient memory usage
  2. Porting code from other languages with unions (especially C) is infeasible without them. The relevant data members could be type-punned using pointer type casting, but this doesn't scale well and complicates porting

Yup, union types are definitely planned. I'm thinking something more elegant than C, probably provide language support for tagged unions that would reduce programmer error and be better to use.

Hohoho, as of version 0.33.0 i am glad to announce that after 4 long years unions are in!

Congratulations! :)