Subject: help with CLtL1/CLtL2 packages

From: [email-masked] (Joerg-Cyril Hoehle)
Date: Fri, 27 Jan 95 14:28:08 +0100

Hi,

I believe that the most incompatible change from CLtL1 to CLtL2 was
the modification of IN-PACKAGE.

I want to write a CLtL1 and CLtL2 (and somewhere in between, like
CLISP) compatible program.

I learnt that I must avoid defpackage altogether because my package is
growing. More symbols will be exported by later files and even at
run-time. CLtL2 p.272 says that "The existing package is modified, if
possible, to reflect the new definition." When I reloaded the file
containing defpackage (maybe because of a reload-system command),
previously exported symbols where unexported and I got lots of weird
errors.

Now it seems that I can find no portable way of defining a package and
this while only testing with CMUCL, CLISP and GCLISP.

I tried the following

;;;

;; Rationale: defpackage avoids crazy eval-when forms and compiler
;; dependencies, but it is only suited for a static package definition. Ours
;; is growing, so we use the normal export and use-package functions in order
;; to avoid problems with reloading and redefining because the use and export
;; lists are augmented in later files.

(eval-when (load compile eval)
  (unless (find-package "B-P")
    (make-package "BGP-MS-PROGRAMMER"
		  :nicknames '("B-P" "SBONE")
		  :use '(#+CLtL2 "COMMON-LISP" #-CLtL2 "LISP"))))

(in-package "B-P")

;; Prepare ASCON
#+CLISP					;has ! built-in in LISP
(shadowing-import '(ascon:!))
#+MIT-LOOP
(shadowing-import '(mit-loop:LOOP mit-loop:DEFINE-LOOP-PATH))

(use-package '("BGP-MS" "ASCON"))

(export
 '(
   ;;ASCON
   ADD-ASSERTION REM-ASSERTION FETCH
   PATTERN-MATCHER-READTABLE

   ...
)

;; I didn't want to duplicate the names between the packages (jch)
(do-external-symbols (sym "BGP-MS")
    (export sym))

CLISP doesn't like the MAKE-PACKAGE form, because the compiler
obviously does weird things when compiling this. On the other hand, I
can't use (IN-PACKAGE ...) with :NICKNAMES or :USE because this form
is CLtL1 only.

Any form I've tried so far runs on a few systems and not on others.

I'm now wondering if the following could possibly work:

#+CLtL2
(eval-when (load compile eval)
  (unless (find-package "B-P")
    (make-package "BGP-MS-PROGRAMMER"
		  :nicknames '("B-P" "SBONE")
		  :use '("COMMON-LISP"))))
#+CLtL2
(in-package "B-P")
#-CLtL2
(in-package "B-P"
  :nicknames '("B-P" "SBONE")
  :use '("LISP"))

Help!
 	Joerg Hoehle.
[email-masked]

PS: is :CLtL2 a feature that CLtL2-complying LISP implementations
provide, so that conditional code can be written with #+CLtL2?