Common Lisp exporting symbols from packages

前端 未结 4 2088
甜味超标
甜味超标 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

    There is a way with the cl-annot package. Its export-slots, export-accessors, export-constructors allow to automatically export them. It works for classes and structures.

    For example,

    @export-accessors
    (defclass foo ()
         ((bar :reader bar-of)
          (bax :writer bax-of)
          (baz :accessor baz-of)))
    

    is equivalent to

    (progn
      (export '(bar-of bax-of baz-of))
      (defclass foo ()
         ((bar :reader bar-of)
          (bax :writer bax-of)
          (baz :accessor baz-of))))
    

提交回复
热议问题