newLISP Fan Club

Forum => Anything else we might add? => Topic started by: Fanda on January 12, 2007, 04:52:02 AM

Title: behaviour of (symbols)
Post by: Fanda on January 12, 2007, 04:52:02 AM
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
Title:
Post by: Lutz on January 12, 2007, 08:54:48 AM
'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