chiark / gitweb /
runlisp-base.conf: Formally allocate `#N=...' ID numbers.
authorMark Wooding <mdw@distorted.org.uk>
Mon, 4 Mar 2024 01:01:13 +0000 (01:01 +0000)
committerMark Wooding <mdw@distorted.org.uk>
Mon, 4 Mar 2024 01:01:13 +0000 (01:01 +0000)
The `@COMMON' definitions get 1000--9999, and users get everything else.

Make a note of this, and renumber all of the code fragments.

runlisp-base.conf

index ea321560f893a26b7644eeb4e5dda2cc04dbf1e3..d733c1c06aa54c277d87e236bbecf5de641c7770 100644 (file)
 ;;;--------------------------------------------------------------------------
 [@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
@@ -158,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
@@ -291,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*
@@ -300,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 =