From fde803745eb106cd61bda52c52a071f69d3b0ae8 Mon Sep 17 00:00:00 2001 From: Andrea Ferretti Date: Thu, 11 Oct 2018 15:59:14 +0200 Subject: [PATCH] Clarify that term rewriting macros are applied recursively (#9305) Fixes https://github.com/nim-lang/Nim/issues/9288 fixes https://github.com/nim-lang/Nim/issues/8376 and fixes https://github.com/nim-lang/Nim/issues/2901 (cherry picked from commit 160f8599c6836f5ade1ba35321141d8de94581f7) --- doc/manual.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/doc/manual.rst b/doc/manual.rst index 588da07e2c..d64da0e3f8 100644 --- a/doc/manual.rst +++ b/doc/manual.rst @@ -5965,6 +5965,12 @@ curlies is the pattern to match against. The operators ``*``, ``**``, notation, so to match verbatim against ``*`` the ordinary function call syntax needs to be used. +Term rewriting macro are applied recursively, up to a limit. This means that +if the result of a term rewriting macro is eligible for another rewriting, +the compiler will try to perform it, and so on, until no more optimizations +are applicable. To avoid putting the compiler into an infinite loop, there is +a hard limit on how many times a single term rewriting macro can be applied. +Once this limit has been passed, the term rewriting macro will be ignored. Unfortunately optimizations are hard to get right and even the tiny example is **wrong**: