diff options
Diffstat (limited to 'doc')
-rw-r--r-- | doc/manual.rst | 1 | ||||
-rw-r--r-- | doc/manual_experimental.rst | 20 | ||||
-rw-r--r-- | doc/tut2.rst | 2 |
3 files changed, 21 insertions, 2 deletions
diff --git a/doc/manual.rst b/doc/manual.rst index 0de96077e..ac66c2550 100644 --- a/doc/manual.rst +++ b/doc/manual.rst @@ -6020,7 +6020,6 @@ In the example a new pragma named ``rtl`` is introduced that either imports a symbol from a dynamic library or exports the symbol for dynamic library generation. - Disabling certain messages -------------------------- Nim generates some warnings and hints ("line too long") that may annoy the diff --git a/doc/manual_experimental.rst b/doc/manual_experimental.rst index 2adfa01c1..a341f33de 100644 --- a/doc/manual_experimental.rst +++ b/doc/manual_experimental.rst @@ -1589,6 +1589,26 @@ having unknown lock level as well: g.memberProc() +noRewrite pragma +---------------- + +Term rewriting macros and templates are currently greedy and +they will rewrite as long as there is a match. +There was no way to ensure some rewrite happens only once, +eg. when rewriting term to same term plus extra content. + +``noRewrite`` pragma can actually prevent further rewriting on marked code, +e.g. with given example ``echo("ab")`` will be rewritten just once: + +.. code-block:: nim + template pwnEcho{echo(x)}(x: expr) = + {.noRewrite.}: echo("pwned!") + + echo "ab" + +``noRewrite`` pragma can be useful to control term-rewriting macros recursion. + + Taint mode ========== diff --git a/doc/tut2.rst b/doc/tut2.rst index 44b76f5ac..d9a37f7ec 100644 --- a/doc/tut2.rst +++ b/doc/tut2.rst @@ -605,7 +605,7 @@ performed before the expression is passed to the template. If the template has no explicit return type, ``void`` is used for consistency with procs and methods. -To pass a block of statements to a template, use 'untyped' for the last parameter: +To pass a block of statements to a template, use ``untyped`` for the last parameter: .. code-block:: nim :test: "nim c $1" |