I want to get a list of all variables that I have created in a lisp session. I think that this should be possible by looking at all symbols interned in common-lisp-user. But how can I get such a list?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
To get bound variables only from cl-user
you iterate all bound symbols with do-symbols
and exclude the symbols, that are imported from other packages:
(let ((external-symbols (mapcan (lambda (pkg)
(let (rez)
(do-symbols (s pkg rez)
(push s rez))))
(package-use-list (find-package 'cl-user)))))
(do-symbols (s 'cl-user)
(when (and (boundp s)
(not (member s external-symbols)))
(print s))))
回答2:
You can use do-symbols
to find the symbols in the common-lisp-user
package.
See the CLHS entry for Macro DO-SYMBOLS, DO-EXTERNAL-SYMBOLS, DO-ALL-SYMBOLS