Strangely, on my computer it did work. The compiler did not complain that value
was not declared, but you were missing a `len` call to the parameter. By the
way, you can also extract the exact identifier that is used in the setter, and
therefore make shure that it is defined.
macro maxLength*(limit: Natural, setterProc: untyped): untyped =
let paramIdent = setterProc.params[2][0]
let lengthValidation = quote do: # This is the part I
can't figure out.
if len(`paramIdent`) > `limit`: # Obviously, this
doesn't work since: value is undeclared,
raise newException(RangeError, "Too long") # and even if I
extract the variable from ``setterProc``, its value is unknown
setterProc.body.insert(0, lengthValidation)
result = setterProc