push and pop pragmas

The push/pop pragmas are very similar to the option directive, but are used to override the settings temporarily. Example:

  1. {.push checks: off.}
  2. # compile this section without runtime checks as it is
  3. # speed critical
  4. # ... some code ...
  5. {.pop.} # restore old settings

push/pop can switch on/off some standard library pragmas, example:

  1. {.push inline.}
  2. proc thisIsInlined(): int = 42
  3. func willBeInlined(): float = 42.0
  4. {.pop.}
  5. proc notInlined(): int = 9
  6. {.push discardable, boundChecks: off, compileTime, noSideEffect, experimental.}
  7. template example(): string = "https://nim-lang.org"
  8. {.pop.}
  9. {.push deprecated, hint[LineTooLong]: off, used, stackTrace: off.}
  10. proc sample(): bool = true
  11. {.pop.}

For third party pragmas it depends on its implementation, but uses the same syntax.