runlisp-base.conf: Formally allocate `#N=...' ID numbers.
[runlisp] / runlisp-base.conf
index 00bfa91..d733c1c 100644 (file)
@@ -26,7 +26,7 @@
 ;; Variables are looked up starting in the home (or explicitly specified)
 ;; section, then proceeding to the parents assigned to `@PARENTS'.
 ;; (`@PARENTS' usually defaults to `@COMMON'; the parent of `@COMMON' is
-;; `@BUILTIN'; `@BUILTIN' and `@CONFIG' have no parents.)
+;; `@BUILTIN'; `@BUILTIN' and `@ENV' have no parents.)
 ;;
 ;; At top-level, the text is split into words at whitespace, unless prevented
 ;; by double- and single-quote, or escaped by `\'.  Within single quotes, all
 ;;;--------------------------------------------------------------------------
 [@COMMON]
 
+;; In order to avoid leaking symbols in `cl-user', the code fragments here
+;; and in implementation definitions need to use uninterned symbols for their
+;; local names, and use `#N=' and `#N#' reader macros to refer to them.  In
+;; order to prevent conflicts with the ID numbers in these, the fragments
+;; here use ID numbers from 1000 up to 9999, leaving 0--999 (and, if you
+;; really need them, 10000 on upwards) for individual implementations.
+
 ;; Turn `#!' into a comment-to-end-of-line.  This is used in all Lisp
 ;; invocations, even though some of them don't apparently need it.  For
 ;; example, SBCL ignores an initial line beginning `#!' as a special feature
 ignore-shebang =
        (set-dispatch-macro-character
         #\\# #\\!
-        (lambda (#1=#:stream #2=#:char #3=#:arg)
-          (declare (ignore #2# #3#))
-          (values (read-line #1#))))
+        (lambda (#1000=#:stream #1001=#:char #1002=#:arg)
+          (declare (ignore #1001# #1002#))
+          (values (read-line #1000#))))
 
 ;; Clear all present symbols from the `COMMON-LISP-USER' package.  Some Lisps
 ;; leave débris in `COMMON-LISP-USER' -- for example, ECL leaves some
 ;; allegedly useful symbols lying around, while ABCL has a straight-up bug in
 ;; its `adjoin.lisp' file.
 clear-cl-user =
-       (let ((#4=#:pkg (find-package "COMMON-LISP-USER")))
-         (with-package-iterator (#5=#:next #4# :internal)
-           (loop (multiple-value-bind (#6=#:anyp #7=#:sym #8=#:how)
-                     (#5#)
-                   (declare (ignore #8#))
-                   (unless #6# (return))
-                   (unintern #7# #4#)))))
+       (let ((#1200=#:pkg (find-package "COMMON-LISP-USER")))
+         (with-package-iterator (#1201=#:next #1200# :internal)
+           (loop (multiple-value-bind (#1202=#:anyp #1203=#:sym #1204=#:how)
+                     (#1201#)
+                   (declare (ignore #1204#))
+                   (unless #1202# (return))
+                   (unintern #1203# #1200#)))))
 
 ;; Add `:runlisp-script' to `*features*' so that scripts can tell whether
 ;; they're supposed to sit quietly and be debugged in a Lisp session or run
@@ -111,12 +118,17 @@ dump-image-prelude =
          ${ignore-shebang}
          ${set-script-feature})
 
+;; An expression to determine the version information for the running Lisp.
+lisp-version =
+       (list (list* \'lisp
+                    (lisp-implementation-type)
+                    (multiple-value-list (lisp-implementation-version)))
+             (cons \'asdf
+                   (asdf:component-version (asdf:find-system "asdf"))))
+
 ;; Full pathname to custom image.
 image-path = ${@image-dir}/${image-file}
 
-;; Command to delete image.
-delete-image = rm -f ${image-path}
-
 ;;;--------------------------------------------------------------------------
 [sbcl]
 
@@ -153,13 +165,13 @@ dump-image =
        ${command} -b -n -Q
                -e "${dump-image-prelude}"
                -e "(ccl::in-development-mode
-                     (let ((#1=#:real-ccl-dir (ccl::ccl-directory)))
+                     (let ((#0=#:real-ccl-dir (ccl::ccl-directory)))
                        (defun ccl::ccl-directory ()
-                         (let* ((#2=#:dirpath
+                         (let* ((#1=#:dirpath
                                   (ccl:getenv \"CCL_DEFAULT_DIRECTORY\")))
-                           (if (and #2# (plusp (length (namestring #2#))))
-                               (ccl::native-to-directory-pathname #2#)
-                               #1#))))
+                           (if (and #1# (plusp (length (namestring #1#))))
+                               (ccl::native-to-directory-pathname #1#)
+                               #0#))))
                      (compile 'ccl::ccl-directory))"
                -e "(ccl:save-application \"${@image-new|q}\"
                                          :init-file nil
@@ -230,8 +242,8 @@ run-script =
        $?@image{"${image-path}" -s "${@script}" |
                 ${@ENV:ECL?ecl} "${@ecl-opt}norc"
                         "${@ecl-opt}eval" "(progn
-                                           ${run-script-prelude}
-                                           ${clear-cl-user})"
+                                             ${run-script-prelude}
+                                             ${clear-cl-user})"
                         "${@ecl-opt}shell" "${@script}"}
                --
 
@@ -248,15 +260,16 @@ image-file = ${@name}+asdf.core
 run-script =
        ${command}
                $?@image{-core "${image-path}" -eval "${image-restore}" |
-                        -batch -noinit -nositeinit -quiet
+                        -batch -noinit -quiet
                                 -eval "(progn
                                          (setf ext:*require-verbose* nil)
-                                         ${run-script-prelude})"}
+                                         ${run-script-prelude}
+                                         ${clear-cl-user})"}
                -load "${@script}" -eval "(ext:quit)" --
 
 dump-image =
-       ${command} -batch -noinit -nositeinit -quiet
-               -eval "${dump-image-prelude}"
+       ${command} -batch -noinit -quiet
+               -eval "(progn ${dump-image-prelude} ${clear-cl-user})"
                -eval "(ext:save-lisp \"${@image-new|q}\"
                                      :batch-mode t :print-herald nil
                                      :site-init nil :load-init-file nil)"
@@ -285,7 +298,7 @@ dump-image =
 command = ${@ENV:ABCL?abcl}
 
 abcl-startup =
-       (let ((#9=#:script "${@script|q}"))
+       (let ((#0=#:script "${@script|q}"))
          ${run-script-prelude}
          ${clear-cl-user}
          (setf *error-output*
@@ -294,9 +307,9 @@ abcl-startup =
                             (java:jfield "java.lang.System" "err")
                             \'character
                             java:+true+))
-         (handler-case (load #9# :verbose nil :print nil)
+         (handler-case (load #0# :verbose nil :print nil)
            (error (error)
-             (format *error-output* "~A (unhandled error): ~A~%" #9# error)
+             (format *error-output* "~A (unhandled error): ~A~%" #0# error)
            (ext:quit :status 255))))
 
 run-script =