Maybe I've just missed it in the documentation: Is there a way to update a 
**(ref) object** by doing something like `person["name"] = "John"` or 
`set(person, "name", "John")`, like with tables? I've quickly tested someting 
like this with a simple macro:
    
    
    import macros
    
    macro setKeyByString(ent: ref object | object, field: string, value: 
untyped): untyped =
      var dotExpr = newNimNode(nnkDotExpr)
      dotExpr.add(ent)
      dotExpr.add(newIdentNode($field))
      newAssignment(dotExpr, value)
    
    
    Run

But I'm kinda worried that I'm reinventing wheel here. Is something like this 
already in the standard library? 

Reply via email to