Skip to content

Efficient (unboxed) tagged unions #388

@mneumann

Description

@mneumann
  • Think of :enum with some payload.
  • At the moment it is unclear whether returning or yielding U64 | I64 | F64 | Pair(U64, U64) will be boxed or not.
  • Boxing would forbid these kind of types in performance critical code.
  • Either we have to trust the compiler to optimize accordingly or introduce a new type Union(A | B | C) that would enforce un-boxing.

Would be nice to write code like this:


:fun some_values
  :yields (U64 | None | F64)
  yield U64[1]
  yield None
  yield F64[1.3]

:fun caller
  @some_values -> (|value|
    case value <: (
    | U64 |  ...
    | None | ...
    | F64 | ...
    )
  )

Metadata

Metadata

Assignees

No one assigned

    Labels

    BLOCKEDWe can't or shouldn't work on this yet, for reasons explained in the ticket and/or comments.complexity 2: significantThis is non-trivial, but still not a major undertakingkind: feature: languageAdding a new language feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions