diff --git a/src/package.lisp b/src/package.lisp index 32a6eae8..d8141cb9 100644 --- a/src/package.lisp +++ b/src/package.lisp @@ -93,17 +93,30 @@ `(eval-when (:compile-toplevel :load-toplevel :execute) (setq *package* (find-package-or-fail ',string-designator)))) -(defmacro defpackage (package &rest options) - (let (use) + +(defmacro defpackage (name &rest options) + (let (exports use) (dolist (option options) (ecase (car option) + (:export + (setf exports (append exports (cdr option)))) (:use (setf use (append use (cdr option)))))) `(progn (eval-when (:load-toplevel :execute) - (%defpackage ',(string package) ',use)) + (let ((package (%defpackage ',(string name) ',use))) + (export + (mapcar (lambda (symbol)(intern (symbol-name symbol) package)) ',exports) + package) + package)) (eval-when (:compile-toplevel) - (make-package ',(string package) :use ',use))))) + (let ((package + (or (find-package ,name) + (make-package ',(string name) :use ',use)))) + (export + (mapcar (lambda (symbol)(intern (symbol-name symbol) package)) ',exports) + package) + package))))) (defun %redefine-package (package use)