Common Lisp exporting symbols from packages

前端 未结 4 2074
甜味超标
甜味超标 2021-02-13 05:40

Is there a short way of exporting all the symbols from a package or is it the only way to do it in defpackage. I generally write my code in a file foo.lisp

4条回答
  •  离开以前
    2021-02-13 06:05

    Once the package is created, and all symbols in it created, e.g., by loading your code that implements the package, you can export any symbols you like, e.g., to export all:

    (do-all-symbols (sym (find-package :foo)) (export sym))
    

    You'll probably be happier with

    (let ((pack (find-package :foo)))
      (do-all-symbols (sym pack) (when (eql (symbol-package sym) pack) (export sym))))
    

    which won't try re-exporting everything from used packages.

提交回复
热议问题