Run Nim Code at Compile Time

So, I know that if I define const, Nim will evaluate everything that I assigned to it at compile time, so I could do something like this:

proc compileTimeCode: bool =
  # Put code here
  return true

const _ = compileTimeCode()

and then I can put my code in compileTimeCodeproc.

It works, but it seems messy, complicated, and unintuitive. It also requires more typing than necessary, and hard to drive up.

+4
source share
1 answer

What question? If there is a better way to run code at compile time?

static:
  # Put code here
+8
source

Source: https://habr.com/ru/post/1623681/


All Articles