I even started writing and RFC for this as well (which is probably more generic 
than `reset()`). Didn't finish it and didn't publish, but here is a start (it 
talks about serialization because that was my main example at the time):

* * *

This artificial limitation, paired with compile-time check kind field 
initialization (`ProveInit`) significantly increases complexity of code 
generation logic for (de)serialization implemenentation, specifically for cases 
with nested case fields. Code that otherwise could be written using functions 
that directly load discriminant fields
    
    
    {.cast(safeAssign).}:
      var obj = Variant()
      load(obj.toplevelKind)
      
      case obj.toplevelKind:
        of opt1, opt2: # Can support multiple discriminant values
          load(obj.nestedKind)
    
    
    Run

must currently be written using very verbose pattern
    
    
    var kind1: KindField
    
    load(kind1)
    
    var obj: Obj()
    
    case kind1:
      of opt1:
        var kind2: NestedKind
        load(kind2)
        
        obj = Obj(kind1: opt1, nestedKind: kind2)
      
      of opt2:
        var kind2: NestedKind
        load(kind2)
        
        obj = Obj(kind1: opt2, nestedKind: kind2)
    
    
    
    Run

Reply via email to