| CL packages separate modules by symbol, and for good reason: symbols are used for many things, ranging from macro names, function names, and on to hash keys and type names. Sometimes it might be useful for a module to place a symbol for itself in a global table, without worrying that the symbol might be used by another module - for example, the Anarki call* types table. With that I present resymbol, a macro which changes the symbols of an expression: (require "ssyntaxes.arc")
(def resymbol-fn! (sl e)
(let tb (fill-table (table) sl)
; disallow translations of builtins
(wipe tb!quote tb!quasiquote
tb!unquote tb!unquote-splicing
tb!fn tb!if tb!set)
((afn (e)
(if
(cons? e)
(do
(zap self (car e))
(zap self (cdr e))
e)
(sym? e)
(if (ssyntax e)
(self:ssexpand e)
(tb//idfn e))
; else
e))
e)))
(mac resymbol (sl e)
(resymbol-fn! sl e))
To use: (resymbol (join d>>join)
(map join (car pts) (cadr pts)))
We could also integrate this into a REPL and/or into load: (= my-tl-table '(join d>>join))
(load "my-file.arc" [resymbol-fn! my-tl-table _])
Edit: Hmm. I seem to use 'zap quite a bit... maybe useful to have ssyntax for this? (!self (car e)) maybe?edit2: hmm, this might not be simple after all, we would have to make !self the equivalent of a macro call. hmm. |