I know that there's also macros.staticRead, but I was puzzled by this behavior. Is this a bug?
https://play.nim-lang.org/#ix=3wWE
proc f() =
try:
discard "FAILME".readFile
except:
echo "unreached"
static:
f()
unreached
....io.nim(849) readFile
Error: unhandled exception: cannot open: FAILME [IOError]
I was not even aware that exceptions can work at compile-time at all, but then found yesterday this old thread
https://forum.nim-lang.org/t/625#3389
I think I have to read that thread to get an idea what compile-time exceptions can do for me :-)
I don't understand tour point. It seems perfectly legit to me using try/except to readFile at compile time. For example, i know file can be in two locations, so I try first and then second.
The point here is that this specific exception is not catched (according to given error) event if exceptions generally works at compile time (see linked example)