clean lexical declare symbol

Started by ssqq, January 07, 2015, 06:52:24 AM

Previous topic - Next topic

ssqq

I found all lexical declare symbol would contain a records in global symbols table.


>
(define (sub-name lexical-args) (add lexical-args))
(lambda (lexical-args) (add lexical-args))
> (find "lexical-args" (map term (symbols)))
212
> (delete 'lexical-args)
true
> (find "lexical-args" (map term (symbols)))
nil


When code go back to top level, I think all lexical symbol should *delete* from symbols table. not just set it *nil*.

ssqq

#1
When delete the lexical symbol, the lambda could not work, even re-set it with nil or other value:



> (define (sub-name lexical-args) (add lexical-args))
(lambda (lexical-args) (add lexical-args))
> (sub-name 2)
2
> (delete 'lexical-args)
true
> (sub-name 2)
ERR: symbol is protected : nil
called from user defined function sub-name
> (set 'lexical-args nil)
nil
> (sub-name 2)
ERR: symbol is protected : nil
called from user defined function sub-name
> (set 'lexical-args 2)
2
> (sub-name 2)
ERR: symbol is protected : nil
called from user defined function sub-name