proc a() =
let i = 10
proc c()
proc b(doC: bool) =
if doC:
c()
proc c() =
echo($i)
b(false)
b(true)
a()
It appears there is a problem with b calling c and c calling b even thought there is a forward declaration for c. The Nim compiler is fine with the code but the generated C fails to compiles:
nestTest.c: In function ‘c_92006’: /home/dm2/henry/Languages/Nimbol/nimcache/nestTest.c:314:37: error: ‘HEX3Aenv_92032’ undeclared (first use in this function) LOC2.ClPrc = b_92008; LOC2.ClEnv = HEX3Aenv_92032;
Interesting. I tried several variations of this, declaring c as variable of type proc () prior to b, but no variation worked (the nim compiled, but not the C).
The following is the only variation I got to work:
proc a() =
let i = 10
proc b(doC: bool, c: proc()) =
if doC:
c()
proc c() =
echo($i)
b(false, c)
b(true, c)
a()