Just as an idea, the flexible solution would be to able set discriminant if you 
provide the new value simultaneously with discriminant and reject at compile 
time otherwise.

Something like:
    
    
    var t = Thing(kind: Zeroth, f: 3.14)
    
    t.kind = First # not compiles
    t.i = 12 # fails runtime check
    
    
    (t.kind, t.i) = (First, 12) # successful
    
    

If it is difficult to achieve just disallow all assignments to the discriminant.

Reply via email to