I thought I had something good last night:
    
    
    type Position = object
      x: int
      y: int
    
    type Velocity = object
      dx: int
      dy: int
      dz: int
    
    type Component = Position | Velocity
    
    proc showProps(p: Position) =
      echo p.x, ", ", p.y
    
    proc showProps(v: Velocity) =
      echo v.dx, ", ", v.dy, ", ", v.dz
    
    let p = Position(x: 9, y: 9)
    let v = Velocity(dx: 1, dy: 1, dz: 3)
    
    showProps(p)
    showProps(v)
    
    
    Run

While tedious, it was good.

Then I learned this morning that seq[Component] fails. _sigh_
    
    
     type Position = object
      x: int
      y: int
    
    type Velocity = object
      dx: int
      dy: int
      dz: int
    
    type Component = Position | Velocity
    
    proc showProps(p: Position) =
      echo p.x, ", ", p.y
    
    proc showProps(v: Velocity) =
      echo v.dx, ", ", v.dy, ", ", v.dz
    
    let p = Position(x: 9, y: 9)
    let v = Velocity(dx: 1, dy: 1, dz: 3)
    var s: seq[Component]
    
    s.add(p)
    s.add(v)
    
    echo s
    
    
    Run

Reply via email to