proc t(i: int): string =
if i != 0: return "OK"
echo t(1)
let x = t(0)
echo x
if x == nil: echo "is nil"
if x.isNil: echo "is nil"
if x == "": echo "is nil"
macro mconnect(arg: typed): untyped =
let sci = t(0)
if sci.isNil:
echo "nil1"
if sci == nil:
echo "nil2"
if sci == "":
echo "nil3"
mconnect(0)
$ nim c t.nim
Hint: used config file '/home/stefan/Nim/config/nim.cfg' [Conf]
Hint: system [Processing]
Hint: t [Processing]
nil2
nil3
Hint: [Link]
Hint: operation successful (12093 lines compiled; 0.131 sec total; 16.324MiB peakmem; Debug Build) [SuccessX]
So there is no "nil1" output, indicating sci.isNil is not true as expected (by me).
Yes, I heard that.
I switched to devel because some people complained about gintro not working with devel any more.
Will .isNil and "x == nil" be an alias for "x == "" " in future, or will it be eliminated, so giving compiler errors?
Note that .isNil is working fine in regular code, but not in macros any more.