> To start with a practical example, ...

Syntactic issues aside, you start with an example that cannot be checked for 
exhaustiveness and so is pretty much against the idea of `case`.

The reason why pattern matching needs to be built into the language is not 
convenience (you can get that with a PM macro easily enough even though nobody 
uses that for macros right now) but safety. Right now Nim's case objects are 
not safe:
    
    
    type
      E = enum
        valA, valB
      Obj = object
         case k: E
         of valA: a: int
         of valB: b: string
    
    proc modify(o: var Obj) =
      reset(o)
      o.k = valB
      o.b = "xx"
    
    case x.kind
    of valA:
      modify(x)
      echo x.a
    of valB: ...
    

Reply via email to