Carp/core/Gensym.carp
Erik Svedäng f78fd16a71
refactor: Move code out of Macros.carp into other files (#1014)
* refactor: Move code out of Macros.carp into other files

* fix: Move back some macros needed in --no-core mode

* refactor: Remove weird 'evaluate' macros

* fix: Put back more macros

* fix: Remove transitive loading of Macros.carp

* refactor: Remove ArrayMacros.carp and put 'for' at top of Array.carp instead

* refactor: More splitting up

* refactor: Move back save-docs

* fix: Moved back some stuff

Co-authored-by: Erik Svedang <erik@Eriks-iMac.local>
2020-11-28 12:53:18 +01:00

16 lines
500 B
Plaintext

(doc *gensym-counter* "Is a helper counter for `gensym`.")
(defdynamic *gensym-counter* 1000)
(defndynamic gensym-local [x]
(Symbol.concat ['gensym-generated x]))
(doc gensym-with "Generates symbols dynamically, based on a symbol name.")
(defndynamic gensym-with [x]
(do
(set! *gensym-counter* (inc *gensym-counter*))
(Symbol.concat [x (Symbol.from *gensym-counter*)])))
(doc gensym "Generates symbols dynamically as needed.")
(defndynamic gensym []
(gensym-with 'gensym-generated))