summary refs log tree commit diff stats
path: root/doc
diff options
context:
space:
mode:
authormetagn <metagngn@gmail.com>2024-08-12 16:33:26 +0300
committerGitHub <noreply@github.com>2024-08-12 15:33:26 +0200
commit0c890ff9a70258af8231967229b891df9731a5df (patch)
treef42d7dbf06e1f9441c704f3aebb288457f3ff0ea /doc
parent7a0069a134aae949f310b5936c6a31270dc79316 (diff)
downloadNim-0c890ff9a70258af8231967229b891df9731a5df.tar.gz
opensym as node kind + fixed experimental switch (#23892)
refs https://github.com/nim-lang/Nim/pull/23873#discussion_r1687995060,
fixes #23386, fixes #23385, supersedes #23572

Turns the `nfOpenSym` node flag implemented in #23091 and extended in
#23102 and #23873, into a node kind `nkOpenSym` that forms a unary node
containing either `nkSym` or `nkOpenSymChoice`. Since this affects
macros working on generic proc AST, the node kind is now only generated
when the experimental switch `genericsOpenSym` is enabled, and a new
node flag `nfDisabledOpenSym` is set to the `nkSym` or `nkOpenSymChoice`
when the switch is not enabled so that we can give a warning.

Now that the experimental switch has more reasonable semantics, we
define `nimHasGenericsOpenSym2`.
Diffstat (limited to 'doc')
-rw-r--r--doc/manual_experimental.md11
1 files changed, 10 insertions, 1 deletions
diff --git a/doc/manual_experimental.md b/doc/manual_experimental.md
index 9b52fbd2a..34399e6f9 100644
--- a/doc/manual_experimental.md
+++ b/doc/manual_experimental.md
@@ -2528,7 +2528,9 @@ Injected symbols in generic procs
 With the experimental option `genericsOpenSym`, captured symbols in generic
 routine bodies may be replaced by symbols injected locally by templates/macros
 at instantiation time. `bind` may be used to keep the captured symbols over
-the injected ones regardless of enabling the option.
+the injected ones regardless of enabling the option, but other methods like
+renaming the captured symbols should be used instead so that the code is not
+affected by context changes.
   
 Since this change may affect runtime behavior, the experimental switch
 `genericsOpenSym` needs to be enabled, and a warning is given in the case
@@ -2560,6 +2562,13 @@ proc baz[T](): string =
 assert baz[int]() == "captured"
 ```
 
+This option also generates a new node kind `nnkOpenSym` which contains
+exactly 1 of either an `nnkSym` or an `nnkOpenSymChoice` node. In the future
+this might be merged with a slightly modified `nnkOpenSymChoice` node but
+macros that want to support the experimental feature should still handle
+`nnkOpenSym`, as the node kind would simply not be generated as opposed to
+being removed.
+
 
 VTable for methods
 ==================