diff options
author | Zahary Karadjov <zahary@gmail.com> | 2018-04-18 19:40:08 +0300 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2018-05-07 09:37:49 +0200 |
commit | bdcb72959729a5c4b195f9bf6b2ac8783c27f38e (patch) | |
tree | b0ba8988e45410d1e869b7af35e30bfe57d236f3 /lib/core | |
parent | 7897026e575a4abd44583cd453b8d36cac96327e (diff) | |
download | Nim-bdcb72959729a5c4b195f9bf6b2ac8783c27f38e.tar.gz |
Better support for treating templates and macros as symbols.
This allows you to pass a template or a macro to another macro which can then inspect the implementation of the former template/macro using `getImpl`. Since templates can be freely redefined, this allows you to treat their symbols as compile-time variables that have lexical scope. A motivating PoC example for a logging library taking advantage of this will be provided in the next commit. Implementation details: * The name of a template or a macro will be consider a symbol if the template/macro requires parameters * For parameterless templates/macros, you can use `bindSym`, which was extended to also work outside of compile-time procs.
Diffstat (limited to 'lib/core')
-rw-r--r-- | lib/core/macros.nim | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/core/macros.nim b/lib/core/macros.nim index 1dc067e1a..fa5cd67df 100644 --- a/lib/core/macros.nim +++ b/lib/core/macros.nim @@ -385,7 +385,7 @@ type {.deprecated: [TBindSymRule: BindSymRule].} -proc bindSym*(ident: string, rule: BindSymRule = brClosed): NimNode {. +proc bindSym*(ident: static[string], rule: BindSymRule = brClosed): NimNode {. magic: "NBindSym", noSideEffect.} ## creates a node that binds `ident` to a symbol node. The bound symbol ## may be an overloaded symbol. |