Added future/export.lisp

Pascal J. Bourguignon [2021-07-14 19:26]
Added future/export.lisp
Filename
future/export.lisp
diff --git a/future/export.lisp b/future/export.lisp
new file mode 100644
index 0000000..107548f
--- /dev/null
+++ b/future/export.lisp
@@ -0,0 +1,28 @@
+(in-package "COMMON-LISP-USER")
+
+(defun process-defuns (function form)
+  (cond
+    ((atom form))
+    ((member (car form) '(defun defmacro defgeneric defmethod))
+     (funcall function form))
+    (t
+     (process-defuns function (car form))
+     (process-defuns function (cdr form)))))
+
+(defun defined-symbols (form)
+  (let ((result '()))
+    (flet ((collect (symbol) (push symbol result)))
+      (process-defuns (lambda (form)
+                        (cond
+                          ((symbolp (second form))
+                           (collect (second form)))
+                          ((and (consp (second form))
+                                (eql 'setf (first (second form))))
+                           (collect (second (second form))))))
+                      (macroexpand-1 form))
+      (remove-duplicates result))))
+
+(defun export-symbols (syms)
+  `(:export ,@(sort (mapcar (function string) syms) (function string<))))
+
+
ViewGit