added system.compiles

This commit is contained in:
Araq 2012-07-20 08:49:42 +02:00
commit 1c6f14deee
8 changed files with 65 additions and 5 deletions

View file

@ -2350,5 +2350,15 @@ proc insert*(x: var string, item: string, i = 0) {.noSideEffect.} =
x[j+i] = item[j]
inc(j)
proc compiles*(x: expr): bool {.magic: "Compiles", noSideEffect.} =
## Special compile-time procedure that checks whether `x` can be compiled
## without any semantic error.
## This can be used to check whether a type supports some operation:
##
## .. code-block:: Nimrod
## when not compiles(3 + 4):
## echo "'+' for integers is available"
nil
when defined(initDebugger):
initDebugger()