5 Declaring the Public Interface: exports

AutoLISP has no ‘defpackage’, so nothing in the language records which functions of a library are meant to be called from outside. ALPM provides that missing declaration:

(alpm-define-system 1
 '(name    "geometry"
   exports ("geo-make-point" "geo-intersect" "c:geodraw")
   files   ("points" "lines" "circles")))

exports’ lists the functions (including ‘c:’ commands) that the system offers; everything else is internal by convention. Even before any enforcement exists, this is checked documentation:

(alpm-check-exports "geometry")

reads the sources (recognizing both ‘defun’ and ‘defun-q’), prints warnings — declared names never defined (the interface lies), names published with ‘vl-doc-export’ but missing from the declaration — and returns three lists: ‘(common-export-list only-in-vl-doc-export-list only-in-alpm-export-list)’.

To adopt what the code already exports into the declaration:

(alpm-scan-exports "geometry" nil)     ; look first: what would be merged
(alpm-scan-exports "geometry" T)   ; merge scanned exports into the declaration
(alpm-save-system (alpm-find-system "geometry")
                  "/home/pjb/lisp/geometry/geometry.alpm")  ; persist it