Macro pragmas
Macros and templates can sometimes be called with the pragma syntax. Cases where this is possible include when attached to routine (procs, iterators, etc.) declarations or routine type expressions. The compiler will perform the following simple syntactic transformations:
template command(name: string, def: untyped) = discard
proc p() {.command("print").} = discard
This is translated to:
command("print"):
proc p() = discard
type
AsyncEventHandler = proc (x: Event) {.async.}
This is translated to:
type
AsyncEventHandler = async(proc (x: Event))
When multiple macro pragmas are applied to the same definition, the first one from left to right will be evaluated. This macro can then choose to keep the remaining macro pragmas in its output, and those will be evaluated in the same way.
There are a few more applications of macro pragmas, such as in type, variable and constant declarations, but this behavior is considered to be experimental and is documented in the experimental manual instead.