You might want to use procs as field getters/setters.
type Foo = ref object
proc `a=`(f: Foo, a: cstring) = {.emit: "`f`.a = `a`;".}
proc a(f: Foo) = {.emit: "`result` = `f`.a;".}
proc `b=`(f: Foo, b: cstring) = {.emit: "`f`.b = `b`;".}
proc b(f: Foo) = {.emit: "`result` = `f`.b;".}
let myObj = Foo.new()
myObj.a = "hello"
- How to avoid rendering missing field in js objects andrea
- Re: How to avoid rendering missing field in js objects yglukhov
