By the way, you don't need to capitalize it. Remember Nim is case and
underscore insensitive, so `avar` is the same as `aVar` and `aVAR`.
Or if you wanna do it with a macro still, you could do something like this:
macro checkVar(name: untyped, body: untyped): untyped =
let varName = ident('a' & ($name).capitalizeAscii())
result = quote do:
if (let `varName` = getVar(`name`); `varName` != VNU
Thanks a lot! I'll give it a try :)
P.S. Χαιρετισμούς από Ισπανία!
You don't need a macro a template works fine, I personally use an operator:
template `?=`(name, value): bool = (let name = value; name != invalidId)
Run
I have many (many) instances where I have something like this:
if (let aVar = getVar("var"); aVar != VNULL) {
# do sth
}
Run
I'm trying to replace this with something more concise (preferrably a macro,
which I believe it should work) to avoid all this visual clut