behaviour of (symbols)

Started by Fanda, January 12, 2007, 04:52:02 AM

Previous topic - Next topic

Fanda

There is one thing that I don't understand about function (symbols). Run this as a script:
(set 's1 (symbols))

(define (f x)
  (let (y 2)
    (+ x y)))

(set 's2 (symbols))

(println (difference s2 s1 true))

(exit)


Output that I get is: (f s2 x y)



My question is: Why 'x' or 'y'? Function 'f' was never called and even if it was - 'x' or 'y' are only temporary symbols.



Thanks for answering, Fanda

Lutz

#1
'x' and 'y' are created in the symbol table with contents 'nil, when loading the program. The symbols are created so they can be referenced when loading the code and translating it into an internal format.



'x' and 'y' are locally modified when exeuting 'f'; when leaving the function 'f' they get their old values back. Their values are temporary but the symbols itself are not.



Lutz