flowgrammable / steve-legacy

The Steve programming language
Apache License 2.0
4 stars 0 forks source link

Variant redesign #2

Closed asutton closed 9 years ago

asutton commented 9 years ago

Currently, the discriminated variants are defined as variant(T) { } where T is the discriminator type. However, this design doesn't work well with the existing parameterization mechanics. For example:

def V(t : typename) -> typename = variant(int) {
  0 : bool;
  1 : t;
}

def v: V(int)(0); // Looks weird.

A better approach would be to make the variant dependent on a parameter in the declarator, like this:

def V(n : int) -> typename = variant(n) { ... }

This is more consistent, and the pattern probably generalizes nicely for other dependent types.

asutton commented 9 years ago

Fixed in f26ab70895e5d1a7373d1959d5e67598a99fb505 and a1fcc2e2b52e26a1382bbfc5bdd26bf64d83d223.