I called them 'supernatural' because it appears that they know what happens around them very first moment they are mentioned in the program.
This is how I did it: Lutz just said that symbols are inserted into symbol table (symbol) during some preparation phase of the expression evaluation. So, symbols are already in (symbol) on the beginning of the evaluation of some block - even if subexpressions that mention these simbols for a first time weren't evaluated yet.
Only thing I needed to do is to remember list (symbol) before begin block, and then again on the beginning of the block. The difference between these two contains exactly variables used in block.
Code is for a dramatic effect hidden in the function self-conscious-symbols. But in essence, it is:
Code: Select all
(set 'symbols-initially (symbols))
(begin (dolist(x (difference (symbols) ;this list contains
symbols-initially)) ;Sri ... and x only
(set x (string "Hi. My name is " x ". Ohm...")))
(println Sri-Aurobindo))
; Hi. My name is Sri-Aurobindo. Ohm...