documented the new .gcsafe override pragma

This commit is contained in:
Araq
2017-01-20 20:32:30 +01:00
parent 572fd067cf
commit ebcc88238e
2 changed files with 16 additions and 2 deletions

View File

@@ -49,6 +49,21 @@ To disable the GC-safety checking the ``--threadAnalysis:off`` command line
switch can be used. This is a temporary workaround to ease the porting effort
from old code to the new threading model.
To override the compiler's gcsafety analysis a ``{.gcsafe.}`` pragma block can
be used:
.. code-block:: nim
var
someGlobal: string = "some string here"
perThread {.threadvar.}: string
proc setPerThread() =
{.gcsafe.}:
deepCopy(perThread, someGlobal)
onThreadCreation(setPerThread)
Future directions:

View File

@@ -92,5 +92,4 @@ restrictions / changes:
* Every array access has to be provably within bounds. This is called
the *bounds check*.
* Slices are optimized so that no copy is performed. This optimization is not
yet performed for ordinary slices outside of a ``parallel`` section. Slices
are also special in that they currently do not support negative indexes!
yet performed for ordinary slices outside of a ``parallel`` section.