I know I should open an issue, but I wanted to make you guys laugh too. Okay, I
wanted to check file existence at compile time. Let's read the docs:
> proc existsFile(filename: string): bool {..}
>
> Returns true if the file exists, false otherwise.
No problem. I tried
from os import existsFile
const ex = existsFile("/tmp/a.txt")
echo "Okay"
I got
lib/nim/pure/os.nim(83, 12) Error: cannot 'importc' variable at compile time
Okay. Happy developing.
* I tried to fuck with staticRead \- at least it works at compile time
* I wanted to compile a subprogram (aka "ls" on unix) which will tell me
whether file exists, and call it by _staticExec_.
* I googled.
**Two days** later. Found this [post by
Araq](https://forum.nim-lang.org/t/610/1#3312)
> News.txt (on bigbreak) contains this:
>
> The following procs are now available at compile-time:
>
> math.sqrt, math.ln, math.log10, math.log2, math.exp, math.round, math.arccos,
> math.arcsin, math.arctan, math.arctan2, math.cos, math.cosh, math.hypot,
> math.sinh, math.sin, math.tan, math.tanh, math.pow, math.trunc, math.floor,
> math.ceil, math.fmod, os.getEnv, os.existsEnv, os.dirExists, os.fileExists,
> system.writeFile
Wait, what? **fileExists**?!
... yep.
from os import fileExists
const ex = fileExists("/tmp/a.txt")
echo "Okay"
Okay
I guess you're interested what's the difference:
> proc fileExists(filename: string): bool {..}
>
> Synonym for existsFile
So when you want something to be done at compile time (and it doesn't work) -
just try to reorder the words.
Happy nimming!