Custom macro for if-let statement

2022-09-14 Thread PMunch
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`.

Custom macro for if-let statement

2022-09-13 Thread blashyrk92
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

Custom macro for if-let statement

2022-09-13 Thread drkameleon
Thanks a lot! I'll give it a try :) P.S. Χαιρετισμούς από Ισπανία!

Custom macro for if-let statement

2022-09-13 Thread planetis
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

Custom macro for if-let statement

2022-09-13 Thread drkameleon
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