push和pop编译指示

push/pop 编译指示与option指令非常相似,但用于暂时覆盖设置。 示例:

  1. {.push checks: off.}
  2. # 编译本节而不进行运行时检查,因为它对速度至关重要
  3. # ... some code ...
  4. {.pop.} # 恢复堆栈

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.  
  7. {.push discardable, boundChecks: off, compileTime, noSideEffect, experimental.}
  8. template example(): string = "https://nim-lang.org"
  9. {.pop.}
  10.  
  11. {.push deprecated, hint[LineTooLong]: off, used, stackTrace: off.}
  12. proc sample(): bool = true
  13. {.pop.}

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