I think you need to use a macro to convert the string to a identifier. This is 
something I hacked together that's pretty clean: 
    
    
    import macros
    
    macro createVar(varName: string, value: untyped): untyped =
      let newVar = ident(varName.strVal) # create the new identifier from 
varName
      result = quote do:
        var `newVar` = `value`
    
    createVar("name", 100)
    createVar("cool", "macro")
    
    echo name, cool
    
    
    Run

May I ask what you plan to use this functionality for? :)

Reply via email to