diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2020-03-04 14:28:53 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-04 14:28:53 +0100 |
commit | a0eca7518223a18f3633150de2c8d3c1c9e71560 (patch) | |
tree | 3a3a7690c066e214e073e2a9c2fd33a9876dc7eb /doc | |
parent | 614fb7567c80c3b071394714c3809c005aaad397 (diff) | |
download | Nim-a0eca7518223a18f3633150de2c8d3c1c9e71560.tar.gz |
sink parameter inference for types that have destructors (#13544)
* ensure capitalize doesn't take an inferred sink parameter * sink parameter inference: first version, for now disabled. Changed that sink parameters can be consumed multiple times in order to adhere to our spec. * sink inference can now be disabled with .nosinks; sometimes for proc type interop this is required * fixes yet another critical DFA bug * better implementation that also understands if expressions etc * document sink parameter inference and allow for global disabling
Diffstat (limited to 'doc')
-rw-r--r-- | doc/advopt.txt | 3 | ||||
-rw-r--r-- | doc/destructors.rst | 17 |
2 files changed, 19 insertions, 1 deletions
diff --git a/doc/advopt.txt b/doc/advopt.txt index 59eab4fb9..5c0ed86ee 100644 --- a/doc/advopt.txt +++ b/doc/advopt.txt @@ -49,7 +49,7 @@ Advanced options: --import:PATH add an automatically imported module --include:PATH add an automatically included module --nimcache:PATH set the path used for generated files - see also https://nim-lang.org/docs/nimc.html#compiler-usage-generated-c-code-directory + see also https://nim-lang.org/docs/nimc.html#compiler-usage-generated-c-code-directory -c, --compileOnly:on|off compile Nim files only; do not assemble or link --noLinking:on|off compile Nim and generated files but do not link --noMain:on|off do not generate a main procedure @@ -145,3 +145,4 @@ Advanced options: works better with `--stackTrace:on` see also https://nim-lang.github.io/Nim/estp.html --benchmarkVM:on|off enable benchmarking of VM code with cpuTime() + --sinkInference:on|off en-/disable sink parameter inference (default: on) diff --git a/doc/destructors.rst b/doc/destructors.rst index d2027102a..6d3ed00dd 100644 --- a/doc/destructors.rst +++ b/doc/destructors.rst @@ -256,6 +256,23 @@ An implementation is allowed, but not required to implement even more move optimizations (and the current implementation does not). +Sink parameter inference +======================== + +The current implementation does a limited form of sink parameter +inference. The `.nosinks`:idx: pragma can be used to disable this inference +for a single routine: + +.. code-block:: nim + + proc addX(x: T; child: T) {.nosinks.} = + x.s.add child + +To disable it for a section of code, one can +use `{.push sinkInference: off.}`...`{.pop.}`. + +The details of the inference algorithm are currently undocumented. + Rewrite rules ============= |