clean lexical declare symbol

For the Compleat Fan

clean lexical declare symbol

Postby ssqq » Wed Jan 07, 2015 2:52 pm

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

Code: Select all
>
(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
 
Posts: 88
Joined: Sun May 04, 2014 12:49 pm

Re: clean lexical declare symbol

Postby ssqq » Thu Jan 08, 2015 1:16 am

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

Code: Select all
> (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
ssqq
 
Posts: 88
Joined: Sun May 04, 2014 12:49 pm


Return to Anything else we might add?

Who is online

Users browsing this forum: No registered users and 3 guests

cron