Next: Loading a System, Previous: Installation, Up: ALPM — AutoLISP Package Management — User Manual [Contents]
2 Your First System ¶
Suppose a small library in ‘/home/pjb/lisp/geometry/’:
geometry/
geometry.alpm
points.lsp
lines.lsp
circles.lsp
‘points.lsp’ defines point constructors; ‘lines.lsp’ calls functions
from ‘points.lsp’; ‘circles.lsp’ uses both. Write this in
‘geometry.alpm’:
;;;; System definition for GEOMETRY.
(alpm-define-system 1
'(name "geometry"
version "1.0.0"
description "2D geometry entities and predicates."
files ("points"
(file "lines" depends-on ("points"))
(file "circles" depends-on ("points" "lines")))))
Things to note:
- The leading ‘1’ is the definition format version. It says "the
quoted list that follows uses the version-1 grammar". When a
future ALPM introduces new definition syntax as format 2, your
version-1 files keep working unchanged, and an old ALPM reading a
format-2 file stops with a clear message instead of
misinterpreting it. Always write the format version you are
actually using — today, ‘1’.
- The whole definition is one quoted list passed to the function
‘alpm-define-system’. Don’t forget the quote — AutoLISP has no
macros, and the property names (‘name’, ‘version’, ‘files’,
‘depends-on’, …) are plain symbols that must not be evaluated. In
particular do not write ‘:name’ — in AutoLISP a ‘:symbol’ is not
a keyword, just a symbol like any other; ALPM uses bare symbols
throughout.
- System and file names are strings, compared case-insensitively.
- File names are given without extension (‘.lsp’ is added when
loading).
- The file is named after the system: system ‘"geometry"’ lives in
‘geometry.alpm’. ALPM finds it either as
‘<registry-dir>/geometry.alpm’ or
‘<registry-dir>/geometry/geometry.alpm’ — the layout above uses
the second form, so register the parent directory:
(alpm-register-directory "/home/pjb/lisp" nil)