home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / SOURCE / D / CLISP / CLISPSRC.TAR / clisp-1995-01-01 / src / init.lsp < prev    next >
Encoding:
Text File  |  1994-12-06  |  82.0 KB  |  2,093 lines

  1. ;;;;   INITIALISIERUNGS-FILE
  2.  
  3. (in-package "LISP")
  4.  
  5. (shadow 'system::debug (find-package "SYSTEM"))
  6.  
  7. ;;; Exportierungen:
  8. (export '(
  9. ;; Typen:
  10. array atom bignum bit bit-vector character common compiled-function
  11. complex cons double-float fixnum float function hash-table integer keyword
  12. list #+LOGICAL-PATHNAMES logical-pathname long-float nil null number package
  13. pathname random-state ratio rational readtable real sequence short-float
  14. simple-array simple-bit-vector simple-string simple-vector single-float
  15. standard-char stream string string-char symbol t vector satisfies values mod
  16. signed-byte unsigned-byte
  17. ;; Konstanten:
  18. lambda-list-keywords lambda-parameters-limit nil t call-arguments-limit
  19. multiple-values-limit pi boole-clr boole-set boole-1 boole-2 boole-c1 boole-c2
  20. boole-and boole-ior boole-xor boole-eqv boole-nand boole-nor boole-andc1
  21. boole-andc2 boole-orc1 boole-orc2 most-positive-fixnum most-negative-fixnum
  22. most-positive-short-float least-positive-short-float least-negative-short-float
  23. most-negative-short-float most-positive-single-float
  24. least-positive-single-float least-negative-single-float
  25. most-negative-single-float most-positive-double-float
  26. least-positive-double-float least-negative-double-float
  27. most-negative-double-float most-positive-long-float least-positive-long-float
  28. least-negative-long-float most-negative-long-float
  29. least-positive-normalized-short-float least-negative-normalized-short-float
  30. least-positive-normalized-single-float least-negative-normalized-single-float
  31. least-positive-normalized-double-float least-negative-normalized-double-float
  32. least-positive-normalized-long-float least-negative-normalized-long-float
  33. short-float-epsilon single-float-epsilon double-float-epsilon
  34. long-float-epsilon short-float-negative-epsilon single-float-negative-epsilon
  35. double-float-negative-epsilon long-float-negative-epsilon
  36. char-code-limit char-font-limit char-bits-limit char-control-bit char-meta-bit
  37. char-super-bit char-hyper-bit array-rank-limit array-dimension-limit
  38. array-total-size-limit internal-time-units-per-second
  39. ;; Variablen:
  40. *macroexpand-hook* *package* *modules* *random-state* *evalhook* *applyhook*
  41. + ++ +++ - * ** *** / // /// *standard-input* *standard-output* *error-output*
  42. *query-io* *debug-io* *terminal-io* *trace-output* *read-base* *read-suppress*
  43. *readtable* *print-readably* *print-escape* *print-pretty* *print-circle*
  44. *print-base* *print-radix* *print-case* *print-gensym* *print-level*
  45. *print-length* *print-array* *read-default-float-format*
  46. *default-pathname-defaults* *load-paths* *load-verbose* *load-print*
  47. *load-echo* *load-pathname* *load-truename* *break-on-warnings*
  48. *compile-warnings* *compile-verbose* *compile-print* *compile-file-pathname*
  49. *compile-file-truename* *features*
  50. ;; Funktionen:
  51. coerce type-of upgraded-array-element-type typep subtypep null symbolp
  52. atom consp listp numberp integerp rationalp floatp realp complexp characterp
  53. stringp bit-vector-p vectorp simple-vector-p simple-string-p
  54. simple-bit-vector-p arrayp packagep functionp compiled-function-p commonp eq
  55. eql equal equalp not symbol-value symbol-function fdefinition boundp fboundp
  56. special-form-p set makunbound fmakunbound get-setf-method
  57. get-setf-method-multiple-value apply funcall mapcar maplist mapc mapl mapcan
  58. mapcon values values-list macro-function macroexpand macroexpand-1 proclaim
  59. get remprop symbol-plist getf get-properties symbol-name make-symbol
  60. copy-symbol gensym gentemp symbol-package keywordp make-package in-package
  61. find-package package-name package-nicknames rename-package package-use-list
  62. package-used-by-list package-shadowing-symbols list-all-packages intern
  63. find-symbol unintern export unexport import shadowing-import shadow
  64. use-package unuse-package find-all-symbols provide require zerop plusp minusp
  65. oddp evenp = /= < > <= >= max min + - * / 1+ 1- conjugate gcd lcm exp expt
  66. log sqrt isqrt abs phase signum sin cos tan cis asin acos atan sinh cosh tanh
  67. asinh acosh atanh float rational rationalize numerator denominator floor
  68. ceiling truncate round mod rem ffloor fceiling ftruncate fround decode-float
  69. scale-float float-radix float-sign float-digits float-precision
  70. integer-decode-float complex realpart imagpart logior logxor logand logeqv
  71. lognand lognor logandc1 logandc2 logorc1 logorc2 boole lognot logtest logbitp
  72. ash logcount integer-length byte byte-size byte-position ldb ldb-test mask-field
  73. dpb deposit-field random make-random-state random-state-p standard-char-p
  74. graphic-char-p string-char-p alpha-char-p upper-case-p lower-case-p
  75. both-case-p digit-char-p alphanumericp char= char/= char< char> char<= char>=
  76. char-equal char-not-equal char-lessp char-greaterp char-not-greaterp
  77. char-not-lessp char-code char-bits char-font code-char make-char character
  78. char-upcase char-downcase digit-char char-int int-char char-name name-char
  79. char-bit set-char-bit elt subseq copy-seq length reverse nreverse
  80. make-sequence concatenate map map-into some every notany notevery reduce fill
  81. replace remove remove-if remove-if-not delete delete-if delete-if-not
  82. remove-duplicates delete-duplicates substitute substitute-if
  83. substitute-if-not nsubstitute nsubstitute-if nsubstitute-if-not find find-if
  84. find-if-not position position-if position-if-not count count-if count-if-not
  85. mismatch search sort stable-sort merge car cdr caar cadr cdar cddr caaar
  86. caadr cadar caddr cdaar cdadr cddar cdddr caaaar caaadr caadar caaddr cadaar
  87. cadadr caddar cadddr cdaaar cdaadr cdadar cdaddr cddaar cddadr cdddar cddddr
  88. cons tree-equal endp list-length nth first second third fourth fifth sixth
  89. seventh eighth ninth tenth rest nthcdr last list list* make-list append
  90. copy-list copy-alist copy-tree revappend nconc nreconc butlast nbutlast ldiff
  91. rplaca rplacd subst subst-if subst-if-not nsubst nsubst-if nsubst-if-not sublis
  92. nsublis member member-if member-if-not tailp adjoin union nunion intersection
  93. nintersection set-difference nset-difference set-exclusive-or
  94. nset-exclusive-or subsetp acons pairlis assoc assoc-if assoc-if-not rassoc
  95. rassoc-if rassoc-if-not make-hash-table hash-table-p gethash remhash maphash
  96. clrhash hash-table-count sxhash make-array vector aref svref
  97. array-element-type array-rank array-dimension array-dimensions
  98. array-total-size array-in-bounds-p array-row-major-index adjustable-array-p
  99. bit sbit bit-and bit-ior bit-xor bit-eqv bit-nand bit-nor bit-andc1 bit-andc2
  100. bit-orc1 bit-orc2 bit-not array-has-fill-pointer-p fill-pointer vector-push
  101. vector-push-extend vector-pop adjust-array char schar string= string-equal
  102. string< string> string<= string>= string/= string-lessp string-greaterp
  103. string-not-greaterp string-not-lessp string-not-equal make-string string-trim
  104. string-left-trim string-right-trim string-upcase string-downcase
  105. string-capitalize nstring-upcase nstring-downcase nstring-capitalize string
  106. eval evalhook applyhook constantp make-synonym-stream make-broadcast-stream
  107. make-concatenated-stream make-two-way-stream make-echo-stream
  108. make-string-input-stream make-string-output-stream get-output-stream-string
  109. streamp input-stream-p output-stream-p stream-element-type interactive-stream-p
  110. close copy-readtable readtablep set-syntax-from-char set-macro-character
  111. get-macro-character make-dispatch-macro-character
  112. set-dispatch-macro-character get-dispatch-macro-character readtable-case
  113. read read-preserving-whitespace read-delimited-list read-line read-char
  114. unread-char peek-char listen read-char-no-hang clear-input read-from-string
  115. parse-integer read-byte write prin1 print pprint princ write-to-string
  116. prin1-to-string princ-to-string write-char write-string write-line terpri
  117. fresh-line finish-output force-output clear-output write-byte format y-or-n-p
  118. yes-or-no-p wild-pathname-p pathname-match-p translate-pathname
  119. #+LOGICAL-PATHNAMES logical-pathname
  120. #+LOGICAL-PATHNAMES translate-logical-pathname
  121. #+LOGICAL-PATHNAMES logical-pathname-translations
  122. #+LOGICAL-PATHNAMES load-logical-pathname-translations
  123. compile-file-pathname pathname truename parse-namestring merge-pathnames
  124. make-pathname pathnamep pathname-host pathname-device pathname-directory
  125. pathname-name pathname-type pathname-version namestring file-namestring
  126. directory-namestring host-namestring enough-namestring user-homedir-pathname
  127. open rename-file delete-file probe-file file-write-date file-author
  128. file-position file-length load directory error cerror warn break compile
  129. compile-file disassemble
  130. documentation  variable structure type ; drei Dokumentations-Typen
  131. describe inspect room ed dribble apropos apropos-list get-decoded-time
  132. get-universal-time decode-universal-time encode-universal-time
  133. get-internal-run-time get-internal-real-time sleep lisp-implementation-type
  134. lisp-implementation-version machine-type machine-version machine-instance
  135. software-type software-version short-site-name long-site-name identity
  136. ;; Special-forms:
  137. eval-when quote function setq progn let let* locally compiler-let progv flet
  138. labels macrolet symbol-macrolet if block return-from tagbody go
  139. multiple-value-call multiple-value-prog1 catch unwind-protect throw declare
  140. the load-time-value
  141. ;; Macros:
  142. deftype defun defvar defparameter defconstant and or psetq setf psetf shiftf
  143. rotatef define-modify-macro defsetf define-setf-method prog1 prog2
  144. when unless cond
  145. case typecase  otherwise ; otherwise als Marker fⁿr die catchall-clause
  146. return loop do do* dolist dotimes prog prog* multiple-value-list
  147. multiple-value-bind multiple-value-setq defmacro remf do-symbols
  148. do-external-symbols do-all-symbols incf decf push pushnew pop defstruct
  149. with-open-stream with-input-from-string with-output-to-string with-open-file
  150. check-type assert etypecase ctypecase ecase ccase trace untrace step time
  151. english deutsch francais
  152. ;; sonstige Markierer:
  153. eval load compile ; EVAL-WHEN-Situationen
  154. special type ftype function inline notinline ignore optimize speed space
  155. safety compilation-speed debug declaration compile ; DECLARE-Specifier
  156. interpreter compiler ; Features
  157. ))
  158.  
  159. (sys::%proclaim-constant 'lambda-list-keywords
  160.   '(&optional &rest &key &allow-other-keys &aux &body &whole &environment)
  161. )
  162. (export lambda-list-keywords)
  163.  
  164. (sys::%putd 'exit #'sys::%exit)
  165. (sys::%putd 'quit #'sys::%exit)
  166. (sys::%putd 'bye #'sys::%exit)
  167. (export '(exit quit bye))
  168.  
  169. (export 'the-environment)
  170.  
  171. (proclaim '(special *features*))
  172. ; Nach der Initialisierung (in IO.Q bzw. SPVW.D) enthΣlt *features*
  173. ; als drittes Symbol  (first (sys::version)) = SYS::CLISP2/3 .
  174. (import *features*)
  175. (export *features*)
  176.  
  177. (in-package "SYSTEM" :nicknames '("SYS" "COMPILER"))
  178. (proclaim '(special compiler::*compiling*))
  179. (setq compiler::*compiling* nil)
  180.  
  181. (in-package "CLOS" :use '("LISP"))
  182. ;;; Exportierungen:
  183. (export '(
  184.   ;; Namen von Funktionen und Macros:
  185.   slot-value slot-boundp slot-makunbound slot-exists-p with-slots with-accessors
  186.   find-class class-of defclass defmethod call-next-method next-method-p
  187.   defgeneric generic-function generic-flet generic-labels
  188.   class-name
  189.   no-applicable-method no-primary-method no-next-method
  190.   find-method add-method remove-method
  191.   compute-applicable-methods method-qualifiers function-keywords
  192.   slot-missing slot-unbound
  193.   print-object describe-object
  194.   make-instance initialize-instance reinitialize-instance shared-initialize
  195.   ;; Namen von Klassen:
  196.   standard-class structure-class built-in-class
  197.   standard-object standard-generic-function standard-method
  198.   ;; andere Symbole:
  199.   standard ; Methoden-Kombination
  200. ))
  201.  
  202. (in-package "LISP")
  203. ; Exportierungen von conditio.lsp
  204. (export '(
  205.   handler-bind                  ; vorgezogen fⁿr compiler.lsp
  206.   find-restart compute-restarts ; vorgezogen fⁿr user1.lsp
  207.   invoke-restart-interactively  ; dito
  208.   restart                       ; vermeide Konflikt mit user1.lsp
  209.   continue                      ; vermeide Konflikt mit user1.lsp
  210.   end-of-file                   ; vermeide Konflikt mit init.lsp, user2.lsp
  211.   ; Typen fⁿr error-of-type:
  212.   condition warning serious-condition error storage-condition type-error
  213.   program-error control-error package-error stream-error end-of-file file-error
  214.   cell-error unbound-variable undefined-function arithmetic-error
  215.   division-by-zero floating-point-overflow floating-point-underflow
  216. ))
  217.  
  218. ; Optionale Files wie macros3.lsp, defs2.lsp, loop.lsp, defs3.lsp machen ihre
  219. ; Exportierungen selber.
  220.  
  221.  
  222. (in-package "SYSTEM")
  223.  
  224. #-COMPILER ; nur beim Bootstrappen
  225. (progn
  226.  
  227. ; vorlΣufig soll bei GET_CLOSURE nicht expandiert werden:
  228. (sys::%putd '%expand-lambdabody-main
  229.   (function %expand-lambdabody-main
  230.     (lambda (lambdabody venv fenv)
  231.       (declare (source nil) (ignore venv fenv))
  232.       lambdabody
  233. ) ) )
  234.  
  235. ; vorlΣufig soll defun ganz trivial expandiert werden:
  236. (sys::%putd 'defun
  237.   (cons 'sys::macro
  238.     (function defun
  239.       (lambda (form env)
  240.         (declare (ignore env))
  241.         #|
  242.         (let ((name (cadr form))
  243.               (lambdalist (caddr form))
  244.               (body (cdddr form)))
  245.           `(SYS::%PUTD ',name (FUNCTION ,name (LAMBDA ,lambdalist ,@body)))
  246.         )
  247.         |#
  248.         (let ((name (cadr form)))
  249.           (list 'sys::%putd (list 'quote name)
  250.             (list 'function name (cons 'lambda (cddr form)))
  251.         ) )
  252.     ) )
  253. ) )
  254.  
  255. )
  256.  
  257. (let ((h (cons 'sys::macro
  258.            (function
  259.              (lambda (form env)
  260.                (declare (ignore env))
  261.                (apply #'(lambda (&key &allow-other-keys)) form)
  262.                (list 'SYS::LANGUAGE
  263.                      (getf form 'ENGLISH)
  264.                      (getf form 'DEUTSCH)
  265.                      (getf form 'FRANCAIS)
  266.       )) ) ) ) )
  267.   (sys::%putd 'ENGLISH h)
  268.   (sys::%putd 'DEUTSCH h)
  269.   (sys::%putd 'FRANCAIS h)
  270. )
  271.  
  272. (sys::%putd 'sys::exported-lisp-symbol-p
  273.   (function sys::exported-lisp-symbol-p
  274.     (lambda (symbol)
  275.       (let ((string (symbol-name symbol)))
  276.         (or (let ((p (find-package "LISP")))
  277.               (and p
  278.                 (multiple-value-bind (s f) (find-symbol string p)
  279.                   (and (eq s symbol) (eq f ':external))
  280.             ) ) )
  281.             (let ((p (find-package "COMMON-LISP")))
  282.               (and p
  283.                 (multiple-value-bind (s f) (find-symbol string p)
  284.                   (and (eq s symbol) (eq f ':external))
  285.     ) ) )   ) ) )
  286. ) )
  287.  
  288. (sys::%putd 'sys::remove-old-definitions
  289.   (function sys::remove-old-definitions
  290.     (lambda (symbol) ; entfernt die alten Funktionsdefinitionen eines Symbols
  291.       (if (special-form-p symbol)
  292.         (error-of-type 'error
  293.           (DEUTSCH "~S ist eine Special-Form und darf nicht umdefiniert werden."
  294.            ENGLISH "~S is a special form and may not be redefined."
  295.            FRANCAIS "~S est une forme spΘciale et ne peut pas Ωtre redΘfinie.")
  296.           symbol
  297.       ) )
  298.       (if (and (or (fboundp symbol) (macro-function symbol))
  299.                (sys::exported-lisp-symbol-p symbol)
  300.           )
  301.         (cerror (DEUTSCH "Die alte Definition wird weggeworfen."
  302.                  ENGLISH "The old definition will be lost"
  303.                  FRANCAIS "L'ancienne dΘfinition sera perdue.")
  304.                 (DEUTSCH "D~2@*~:[ie~;er~]~0@* COMMON-LISP-~A ~S wird umdefiniert."
  305.                  ENGLISH "Redefining the COMMON LISP ~A ~S"
  306.                  FRANCAIS "L~2@*~:[a~;e~]~0@* ~A ~S de COMMON-LISP va Ωtre redΘfini~:[e~;~].")
  307.                 (fbound-string symbol) ; "Funktion" bzw. "Macro"
  308.                 symbol
  309.                 (macro-function symbol)
  310.       ) )
  311.       (fmakunbound symbol) ; Funktions-/Macro-Definition streichen
  312.       ; Property sys::definition wird nicht entfernt, da sie sowieso
  313.       ; bald neu gesetzt wird.
  314.       (remprop symbol 'sys::macro) ; Macro-Definition streichen
  315.       (when (get symbol 'sys::documentation-strings) ; Dokumentation streichen
  316.         (sys::%set-documentation symbol 'FUNCTION nil)
  317.       )
  318.       (when (get symbol 'sys::inline-expansion)
  319.         (sys::%put symbol 'sys::inline-expansion t)
  320.       )
  321.       (when (get symbol 'sys::traced-definition) ; Trace streichen
  322.         (warn (DEUTSCH "DEFUN/DEFMACRO: ~S war getraced und wird umdefiniert!"
  323.                ENGLISH "DEFUN/DEFMACRO: redefining ~S; it was traced!"
  324.                FRANCAIS "DEFUN/DEFMACRO : ~S Θtait tracΘe et est redΘfinie!")
  325.               symbol
  326.         )
  327.         (untrace2 symbol)
  328.     ) )
  329. ) )
  330.  
  331. ; THE-ENVIRONMENT wie in SCHEME
  332. (sys::%putd '%the-environment
  333.   (function %the-environment
  334.     (lambda (form env)
  335.       (declare (ignore form))
  336.       (sys::svstore env 0 (svref (svref env 0) 2)) ; *evalhook*-Bindung streichen
  337.       env
  338.     )
  339. ) )
  340. (sys::%putd '%the-environment-error
  341.   (function %the-environment-error
  342.     (lambda ()
  343.       (error-of-type 'program-error
  344.         (DEUTSCH "~S ist in compiliertem Code unm÷glich."
  345.          ENGLISH "~S is impossible in compiled code"
  346.          FRANCAIS "~S est impossible dans du code compilΘ.")
  347.         'the-environment
  348.     ) )
  349. ) )
  350. (sys::%putd 'the-environment
  351.   (cons 'sys::macro
  352.     (function the-environment
  353.       (lambda (form env)
  354.         (declare (ignore form env))
  355.         '(progn
  356.            (eval-when ((not eval)) (%the-environment-error))
  357.            (let ((*evalhook* #'%the-environment)) 0)
  358.          )
  359. ) ) ) )
  360.  
  361. ; liefert den Namen des impliziten Blocks zu einem Funktionsnamen
  362. (defun block-name (funname)
  363.   (if (atom funname) funname (second funname))
  364. )
  365.  
  366. ;;; Funktionen zum Expandieren von Macros innerhalb eines Codestⁿckes
  367. ;;;
  368. ;;; Insgesamt wird der gesamte Code (einer Funktion) durchgegangen und
  369. ;;; globale und lokale Macros expandiert.
  370. ;;; Aus       #'(lambda lambdalist . body)
  371. ;;; wird so   #'(lambda expanded-lambdalist
  372. ;;;               (declare (source (lambdalist . body))) . expanded-body
  373. ;;;             )
  374. ;;; Durch diese Deklaration ist gewΣhrleistet, da▀ eine bereits einmal
  375. ;;; durchlaufene Funktion als solche erkannt und nicht unn÷tigerweise ein
  376. ;;; zweites Mal durchlaufen wird.
  377.  
  378. ; Vorsicht! Fⁿrs Bootstrappen (erkennbar an #-COMPILER) mⁿssen manche der
  379. ; Funktionen in primitiverem Lisp (ohne do, do*, case) geschrieben werden.
  380.  
  381. (PROGN
  382.  
  383. (proclaim '(special *keyword-package*))
  384. (setq *keyword-package* (find-package "KEYWORD"))
  385.  
  386. (proclaim '(special *fenv*))
  387. ; *fenv* = Das aktuelle Function-Environment wΣhrend der Expansion
  388. ; einer Form. Struktur: NIL oder ein 2n+1-elementiger Vektor
  389. ; (n1 f1 ... nn fn next), wo die ni Funktionsnamen sind, die fi ihre funktionale
  390. ; Bedeutung sind (Closure oder (MACRO . Closure) oder noch NIL); bei next
  391. ; geht's ebenso weiter.
  392.  
  393. ; (fenv-assoc s fenv) sucht Symbol s in Function-Environment fenv.
  394. (defun fenv-assoc (s fenv)
  395.   (if fenv
  396.     (if (simple-vector-p fenv)
  397.       #+COMPILER
  398.       (do ((l (1- (length fenv)))
  399.            (i 0 (+ i 2)))
  400.           ((= i l) (fenv-assoc s (svref fenv i)))
  401.         (if (equal s (svref fenv i))
  402.           (return (svref fenv (1+ i)))
  403.       ) )
  404.       #-COMPILER
  405.       (let ((l (1- (length fenv)))
  406.             (i 0))
  407.         (block nil
  408.           (tagbody
  409.             1 (if (= i l) (return-from nil (fenv-assoc s (svref fenv i))))
  410.               (if (equal s (svref fenv i))
  411.                 (return-from nil (svref fenv (1+ i)))
  412.               )
  413.               (setq i (+ i 2))
  414.               (go 1)
  415.       ) ) )
  416.       (error-of-type 'type-error
  417.         :datum fenv :expected-type '(or null simple-vector)
  418.         (DEUTSCH "~S ist kein korrektes Function-Environment."
  419.          ENGLISH "~S is an invalid function environment"
  420.          FRANCAIS "~S n'est pas un environnement de fonctions correct.")
  421.         fenv
  422.     ) )
  423.     'T ; nicht gefunden
  424. ) )
  425. ; Stellt fest, ob ein Funktionsname im Function-Environment fenv nicht
  426. ; definiert ist und daher auf die globale Funktion verweist.
  427. (defun global-in-fenv-p (s fenv) ; vorlΣufig
  428.   (eq (fenv-assoc s fenv) 'T)
  429. )
  430.  
  431. (proclaim '(special *venv*))
  432. ; *venv* = Das aktuelle Variablen-Environment wΣhrend der Expansion
  433. ; einer Form. Struktur: NIL oder ein 2n+1-elementiger Vektor
  434. ; (n1 v1 ... nn vn next), wo die ni Symbole sind, die vi ihre
  435. ; syntaktische Bedeutung (Symbol-Macro-Objekt oder sonstiges); bei next
  436. ; geht's ebenso weiter.
  437.  
  438. ; (venv-assoc s venv) sucht Symbol s in Variablen-Environment venv.
  439. ; Liefert den Wert (oder NIL falls kein Wert).
  440. ; Vorsicht: Der Wert kann #<SPECDECL> oder #<SYMBOL-MACRO ...> sein, darf
  441. ; daher in interpretiertem Code nicht in einer Variablen zwischengespeichert
  442. ; werden.
  443. (defun venv-assoc (s venv)
  444.   (if venv
  445.     (if (simple-vector-p venv)
  446.       #+COMPILER
  447.       (do ((l (1- (length venv)))
  448.            (i 0 (+ i 2)))
  449.           ((= i l) (venv-assoc s (svref venv i)))
  450.         (if (eq s (svref venv i))
  451.           (return (svref venv (1+ i)))
  452.       ) )
  453.       #-COMPILER
  454.       (let ((l (1- (length venv)))
  455.             (i 0))
  456.         (block nil
  457.           (tagbody
  458.             1 (if (= i l) (return-from nil (venv-assoc s (svref venv i))))
  459.               (if (eq s (svref venv i))
  460.                 (return-from nil (svref venv (1+ i)))
  461.               )
  462.               (setq i (+ i 2))
  463.               (go 1)
  464.       ) ) )
  465.       (error-of-type 'type-error
  466.         :datum venv :expected-type '(or null simple-vector)
  467.         (DEUTSCH "~S ist kein korrektes Variablen-Environment."
  468.          ENGLISH "~S is an invalid variable environment"
  469.          FRANCAIS "~S n'est pas un environnement de variables correct.")
  470.         venv
  471.     ) )
  472.     (and (boundp s) (symbol-value s)) ; nicht gefunden
  473. ) )
  474.  
  475. ; Die meisten Expansionsfunktionen liefern zwei Werte: Das Expansions-
  476. ; ergebnis, der zweite Wert (NIL oder T) zeigt an, ob darin etwas verΣndert
  477. ; wurde.
  478.  
  479. ; (%expand-cons ...) setzt ein cons zusammen. 2 Werte.
  480. ; form=alte Form,
  481. ; expf,flagf = Expansion des First-Teils,
  482. ; expr,flagr = Expansion des Rest-Teils.
  483. (defun %expand-cons (form expf flagf expr flagr)
  484.   (if (or flagf flagr)
  485.     (values (cons expf expr) t)
  486.     (values form nil)
  487. ) )
  488.  
  489. #+COMPILER
  490.  
  491. ; (%expand-form form) expandiert eine ganze Form. 2 Werte.
  492. (defun %expand-form (form)
  493.   (if (atom form)
  494.     (let (h)
  495.       (if (and (symbolp form) (symbol-macro-p (setq h (venv-assoc form *venv*))))
  496.         (values (sys::%record-ref h 0) t)
  497.         (values form nil)
  498.     ) )
  499.     ; form ist CONS
  500.     (let ((f (first form)))
  501.       (if (function-name-p f)
  502.         (let ((h (fenv-assoc f *fenv*)))
  503.           ; f ist in *fenv* assoziiert zu h
  504.           (if (eq h 'T)
  505.             ; f hat keine lokale Definition
  506.             ; Nun die einzelnen Expander fⁿr die Special-forms:
  507.             (case f
  508.               ((RETURN-FROM THE)
  509.                 ; 1. Argument lassen, alle weiteren expandieren
  510.                 (multiple-value-call #'%expand-cons form
  511.                   (first form) nil
  512.                   (multiple-value-call #'%expand-cons (rest form)
  513.                     (second form) nil
  514.                     (%expand-list (cddr form))
  515.               ) ) )
  516.               ((QUOTE GO DECLARE LOAD-TIME-VALUE) ; nichts expandieren
  517.                 (values form nil)
  518.               )
  519.               (FUNCTION
  520.                 ; Falls erstes bzw. zweites Argument Liste,
  521.                 ; als Lambda-Ausdruck expandieren.
  522.                 (multiple-value-call #'%expand-cons form
  523.                   'FUNCTION nil
  524.                   (if (atom (cddr form))
  525.                     (if (function-name-p (second form))
  526.                       (let ((h (fenv-assoc (second form) *fenv*)))
  527.                         (cond ((or (eq h 'T) (closurep h) (null h)) (values (rest form) nil))
  528.                               ((and (consp h) (eq (first h) 'MACRO))
  529.                                (error-of-type 'program-error
  530.                                  (DEUTSCH "~S: ~S unzulΣssig, da ~S ein lokaler Macro ist"
  531.                                   ENGLISH "~S: ~S is illegal since ~S is a local macro"
  532.                                   FRANCAIS "~S : ~S est illΘgal car ~S est un macro local")
  533.                                  '%expand form (second form)
  534.                               ))
  535.                               (t (error-of-type 'error
  536.                                    (DEUTSCH "~S: Falscher Aufbau eines Function-Environment: ~S"
  537.                                     ENGLISH "~S: invalid function environment ~S"
  538.                                     FRANCAIS "~S : mauvais environnement de fonction ~S")
  539.                                    '%expand *fenv*
  540.                               )  )
  541.                       ) )
  542.                       (if (atom (second form))
  543.                         (error-of-type 'program-error
  544.                           (DEUTSCH "~S: ~S unzulΣssig, da ~S kein Symbol"
  545.                            ENGLISH "~S: ~S is invalid since ~S is not a symbol"
  546.                            FRANCAIS "~S : ~S est illΘgal car ~S n'est pas un symbole")
  547.                           '%expand form (second form)
  548.                         )
  549.                         (multiple-value-call #'%expand-cons (rest form)
  550.                           (%expand-lambda (second form))
  551.                           (cddr form) nil
  552.                     ) ) )
  553.                     (multiple-value-call #'%expand-cons (rest form)
  554.                       (second form) nil
  555.                       (multiple-value-call #'%expand-cons (cddr form)
  556.                         (%expand-lambda (third form))
  557.                         (cdddr form) nil
  558.               ) ) ) ) )
  559.               (EVAL-WHEN
  560.                 ; Falls die Situation COMPILE angegeben ist, fⁿhre den Body
  561.                 ; als PROGN aus, gib eine Form zurⁿck, die ohne Seiteneffekte
  562.                 ; dieselben Werte liefert.
  563.                 ; Sonst expandiere alle Argumente ab dem zweiten als Formen.
  564.                 (if (member 'COMPILE (second form))
  565.                   (values
  566.                     (list 'values-list
  567.                       (list 'quote
  568.                         (multiple-value-list (eval (cons 'PROGN (cddr form))))
  569.                     ) )
  570.                     t
  571.                   )
  572.                   (multiple-value-call #'%expand-cons form
  573.                     (first form) nil
  574.                     (multiple-value-call #'%expand-cons (rest form)
  575.                       (second form) nil
  576.                       (%expand-list (cddr form))
  577.               ) ) ) )
  578.               (LET ; Variablenliste und Body expandieren
  579.                 (let ((*venv* *venv*))
  580.                   (%expand-special-declarations (cddr form))
  581.                   (multiple-value-call #'%expand-cons form
  582.                     (first form) nil
  583.                     (multiple-value-call #'%expand-cons (rest form)
  584.                       (%expand-varspez (second form))
  585.                       (%expand-list (cddr form))
  586.               ) ) ) )
  587.               (LET* ; Variablenliste und Body expandieren
  588.                 (let ((*venv* *venv*))
  589.                   (%expand-special-declarations (cddr form))
  590.                   (multiple-value-call #'%expand-cons form
  591.                     (first form) nil
  592.                     (multiple-value-call #'%expand-cons (rest form)
  593.                       (%expand-varspez* (second form))
  594.                       (%expand-list (cddr form))
  595.               ) ) ) )
  596.               (LOCALLY ; Body expandieren
  597.                 (let ((*venv* *venv*))
  598.                   (%expand-special-declarations (cdr form))
  599.                   (multiple-value-call #'%expand-cons form
  600.                     (first form) nil
  601.                     (%expand-list (cdr form))
  602.               ) ) )
  603.               (MULTIPLE-VALUE-BIND ; Form und Body getrennt expandieren
  604.                 (let ((*venv* *venv*))
  605.                   (%expand-special-declarations (cdddr form))
  606.                   (multiple-value-call #'%expand-cons form
  607.                     'MULTIPLE-VALUE-BIND nil
  608.                     (multiple-value-call #'%expand-cons (rest form)
  609.                       (second form) nil
  610.                       (multiple-value-call #'%expand-cons (cddr form)
  611.                         (%expand-form (third form))
  612.                         (progn
  613.                           (%expand-lexical-variables (second form))
  614.                           (%expand-list (cdddr form))
  615.               ) ) ) ) ) )
  616.               (COMPILER-LET
  617.                 ; Variablenliste im leeren Environment und Body expandieren
  618.                 (progv
  619.                   (mapcar #'%expand-varspec-var (second form))
  620.                   (mapcar #'%expand-varspec-val (second form))
  621.                   (values (%expand-form (cons 'PROGN (cddr form))) t)
  622.               ) )
  623.               (COND ; Alle Teilformen der Klauseln expandieren:
  624.                 (multiple-value-call #'%expand-cons form
  625.                   (first form) nil
  626.                   (%expand-cond (rest form))
  627.               ) )
  628.               (BLOCK
  629.                 ; Body expandieren. Falls darin ein RETURN-FROM auf diesen
  630.                 ; Block vorkommt, behalte BLOCK. Sonst mache ein PROGN daraus.
  631.                 (multiple-value-bind (body flagb) (%expand-list (cddr form))
  632.                   (if (%return-p (second form) body)
  633.                     (multiple-value-call #'%expand-cons form
  634.                       (first form) nil
  635.                       (multiple-value-call #'%expand-cons (rest form)
  636.                         (second form) nil
  637.                         body flagb
  638.                     ) )
  639.                     (values
  640.                       (cond ((atom body) body)
  641.                             ((null (cdr body)) (car body))
  642.                             (t (cons 'progn body))
  643.                       )
  644.                       t
  645.               ) ) ) )
  646.               ((SETQ PSETQ) ; jedes zweite Argument expandieren
  647.                 (if (%expand-setqlist-macrop (rest form))
  648.                   (let ((new (if (eq (first form) 'SETQ) 'SETF 'PSETF)))
  649.                     (values
  650.                       (%expand-form
  651.                         (funcall (macro-function new) (cons new (rest form)) (vector *venv* *fenv*))
  652.                       )
  653.                       t
  654.                   ) )
  655.                   (multiple-value-call #'%expand-cons form
  656.                     (first form) nil
  657.                     (%expand-setqlist (rest form))
  658.               ) ) )
  659.               (MULTIPLE-VALUE-SETQ ; 1. Argument lassen, alle weiteren expandieren
  660.                 (if (%expand-varlist-macrop (second form))
  661.                   (values (%expand-form (cons 'MULTIPLE-VALUE-SETF (rest form))) t)
  662.                   (multiple-value-call #'%expand-cons form
  663.                     'MULTIPLE-VALUE-SETQ nil
  664.                     (multiple-value-call #'%expand-cons (rest form)
  665.                       (second form) nil
  666.                       (%expand-list (cddr form))
  667.               ) ) ) )
  668.               (TAGBODY
  669.                 ; alle Argumente expandieren, dabei entstehende Atome weglassen
  670.                 (multiple-value-call #'%expand-cons form
  671.                   (first form) nil
  672.                   (%expand-tagbody (rest form))
  673.               ) )
  674.               (PROGN ; alle Argumente expandieren, evtl. vereinfachen.
  675.                 (if (null (rest form))
  676.                   (values nil t)
  677.                   (if (null (cddr form))
  678.                     (values (%expand-form (second form)) t)
  679.                     (multiple-value-call #'%expand-cons form
  680.                       (first form) nil
  681.                       (%expand-list (rest form))
  682.               ) ) ) )
  683.               (FLET ; Funktionsdefinitionen expandieren,
  684.                     ; Body im erweiterten Environment expandieren
  685.                 (if (null (second form))
  686.                   (values (%expand-form (cons 'PROGN (cddr form))) t)
  687.                   (let ((newfenv (%expand-fundefs-1 (second form))))
  688.                     (multiple-value-call #'%expand-cons form
  689.                       (first form) nil
  690.                       (multiple-value-call #'%expand-cons (rest form)
  691.                         (%expand-fundefs-2 (second form))
  692.                         (let ((*fenv* (apply #'vector newfenv)))
  693.                           (%expand-list (cddr form))
  694.               ) ) ) ) ) )
  695.               (LABELS ; Funktionsdefinitionen und Body im erweiterten Environment expandieren
  696.                 (if (null (second form))
  697.                   (values (%expand-form (cons 'PROGN (cddr form))) t)
  698.                   (let ((newfenv (%expand-fundefs-1 (second form))))
  699.                     (let ((*fenv* (apply #'vector newfenv)))
  700.                       (multiple-value-call #'%expand-cons form
  701.                         (first form) nil
  702.                         (multiple-value-call #'%expand-cons (rest form)
  703.                           (%expand-fundefs-2 (second form))
  704.                           (%expand-list (cddr form))
  705.               ) ) ) ) ) )
  706.               (MACROLET ; Body im erweiterten Environment expandieren
  707.                 (do ((L1 (second form) (cdr L1))
  708.                      (L2 nil))
  709.                     ((atom L1)
  710.                      (if L1
  711.                        (error-of-type 'program-error
  712.                          (DEUTSCH "Dotted list im Code von MACROLET, endet mit ~S"
  713.                           ENGLISH "code after MACROLET contains a dotted list, ending with ~S"
  714.                           FRANCAIS "Le code de MACROLET contient une paire pointΘe, terminΘe par ~S")
  715.                          L1
  716.                        )
  717.                        (let ((*fenv* (apply #'vector (nreverse (cons *fenv* L2)))))
  718.                          (values (%expand-form (cons 'PROGN (cddr form))) t)
  719.                     )) )
  720.                   (let ((macrodef (car L1)))
  721.                     (if (and (consp macrodef)
  722.                              (symbolp (car macrodef))
  723.                              (consp (cdr macrodef))
  724.                         )
  725.                       (setq L2
  726.                         (cons (make-macro-expandercons macrodef)
  727.                               (cons (car macrodef) L2)
  728.                       ) )
  729.                       (error-of-type 'program-error
  730.                         (DEUTSCH "Falsche Syntax in MACROLET: ~S"
  731.                          ENGLISH "illegal syntax in MACROLET: ~S"
  732.                          FRANCAIS "syntaxe illΘgale dans MACROLET : ~S")
  733.                         macrodef
  734.               ) ) ) ) )
  735.               (SYMBOL-MACROLET ; Body im erweiterten Environment expandieren
  736.                 (do ((L1 (second form) (cdr L1))
  737.                      (L2 nil))
  738.                     ((atom L1)
  739.                      (if L1
  740.                        (error-of-type 'program-error
  741.                          (DEUTSCH "Dotted list im Code von SYMBOL-MACROLET, endet mit ~S"
  742.                           ENGLISH "code after SYMBOL-MACROLET contains a dotted list, ending with ~S"
  743.                           FRANCAIS "Le code de SYMBOL-MACROLET contient une paire pointΘe, terminΘe par ~S")
  744.                          L1
  745.                        )
  746.                        (let ((*venv* (apply #'vector (nreverse (cons *venv* L2)))))
  747.                          (values (%expand-form (cons 'LOCALLY (cddr form))) t)
  748.                     )) )
  749.                   (let ((symdef (car L1)))
  750.                     (if (and (consp symdef)
  751.                              (symbolp (car symdef))
  752.                              (consp (cdr symdef))
  753.                              (null (cddr symdef))
  754.                         )
  755.                       (setq L2
  756.                         (cons (make-symbol-macro (cadr symdef)) (cons (car symdef) L2))
  757.                       )
  758.                       (error-of-type 'program-error
  759.                         (DEUTSCH "Falsche Syntax in SYMBOL-MACROLET: ~S"
  760.                          ENGLISH "illegal syntax in SYMBOL-MACROLET: ~S"
  761.                          FRANCAIS "syntaxe illΘgale dans SYMBOL-MACROLET : ~S")
  762.                         symdef
  763.               ) ) ) ) )
  764.               (%HANDLER-BIND ; Handlerliste und Body expandieren
  765.                 (multiple-value-call #'%expand-cons form
  766.                   (first form) nil
  767.                   (multiple-value-call #'%expand-cons (rest form)
  768.                     (%expand-handlers (second form))
  769.                     (%expand-list (cddr form))
  770.               ) ) )
  771.               (t
  772.                 (cond ((and (symbolp f) (special-form-p f))
  773.                        ; sonstige Special-forms,
  774.                        ; z.B. IF, CATCH, THROW, PROGV, UNWIND-PROTECT, PROGN,
  775.                        ; PROG1, PROG2, WHEN, UNLESS, MULTIPLE-VALUE-LIST,
  776.                        ; MULTIPLE-VALUE-CALL, MULTIPLE-VALUE-PROG1, AND, OR:
  777.                        (multiple-value-call #'%expand-cons form
  778.                          f nil
  779.                          (%expand-list (rest form))
  780.                       ))
  781.                       ((and (symbolp f) (setq h (macro-function f))) ; globale Macro-Definition
  782.                        (values (%expand-form (funcall h form (vector *venv* *fenv*))) t)
  783.                       )
  784.                       (t ; normaler Funktionsaufruf
  785.                        (multiple-value-call #'%expand-cons form
  786.                          f nil
  787.                          (%expand-list (rest form))
  788.             ) ) )     ))
  789.             ; f hat eine lokale Definition
  790.             (cond ((or (closurep h) (null h)); aufzurufende Funktion
  791.                    (multiple-value-call #'%expand-cons form
  792.                      f nil
  793.                      (%expand-list (rest form))
  794.                   ))
  795.                   ((and (consp h) (eq (car h) 'MACRO)) ; zu expandierender Macro
  796.                    (values (%expand-form (funcall (cdr h) form *fenv*)) t)
  797.                   ) ; Expander aufrufen
  798.                   (t (error-of-type 'error
  799.                        (DEUTSCH "Falscher Aufbau eines Function-Environment in ~S: ~S"
  800.                         ENGLISH "bad function environment occurred in ~S: ~S"
  801.                         FRANCAIS "mauvais environnement de fonction dans ~S : ~S")
  802.                        '%expand-form *fenv*
  803.         ) ) )     )  )
  804.         (if (consp f)
  805.           (multiple-value-call #'%expand-cons form
  806.             (%expand-lambda f)
  807.             (%expand-list (rest form))
  808.           )
  809.           (error-of-type 'program-error
  810.             (DEUTSCH "~S: ~S ist keine korrekte Form"
  811.              ENGLISH "~S: invalid form ~S"
  812.              FRANCAIS "~S : forme Lisp incorrecte ~S")
  813.             '%expand-form form
  814. ) ) ) ) ) )
  815.  
  816. #-COMPILER
  817. (progn
  818.  
  819. ; (%expand-form form) expandiert eine ganze Form. 2 Werte.
  820. (defun %expand-form (form)
  821.   (if (atom form)
  822.     (let (h)
  823.       (if (and (symbolp form) (symbol-macro-p (setq h (venv-assoc form *venv*))))
  824.         (values (sys::%record-ref h 0) t)
  825.         (values form nil)
  826.     ) )
  827.     ; form ist CONS
  828.     (let ((f (first form)))
  829.       (if (function-name-p f)
  830.         (let ((h (fenv-assoc f *fenv*)))
  831.           ; f ist in *fenv* assoziiert zu h
  832.           (if (eq h 'T)
  833.             ; f hat keine lokale Definition
  834.             (cond ((setq h (get '%expand f)) ; special forms u.Σ.
  835.                    (funcall h form)
  836.                   )
  837.                   ((and (symbolp f) (special-form-p f))
  838.                    ; sonstige Special-forms,
  839.                    ; z.B. IF, CATCH, THROW, PROGV, UNWIND-PROTECT, PROGN,
  840.                    ; PROG1, PROG2, WHEN, UNLESS, MULTIPLE-VALUE-LIST,
  841.                    ; MULTIPLE-VALUE-CALL, MULTIPLE-VALUE-PROG1, AND, OR:
  842.                    (multiple-value-call #'%expand-cons form
  843.                      f nil
  844.                      (%expand-list (rest form))
  845.                   ))
  846.                   ((and (symbolp f) (setq h (macro-function f))) ; globale Macro-Definition
  847.                    (values (%expand-form (funcall h form (vector *venv* *fenv*))) t)
  848.                   )
  849.                   (t ; normaler Funktionsaufruf
  850.                    (multiple-value-call #'%expand-cons form
  851.                      f nil
  852.                      (%expand-list (rest form))
  853.             )     ))
  854.             ; f hat eine lokale Definition
  855.             (cond ((or (closurep h) (null h)); aufzurufende Funktion
  856.                    (multiple-value-call #'%expand-cons form
  857.                      f nil
  858.                      (%expand-list (rest form))
  859.                   ))
  860.                   ((and (consp h) (eq (car h) 'MACRO)) ; zu expandierender Macro
  861.                    (values (%expand-form (funcall (cdr h) form *fenv*)) t)
  862.                   ) ; Expander aufrufen
  863.                   (t (error-of-type 'error
  864.                        (DEUTSCH "Falscher Aufbau eines Function-Environment in ~S: ~S"
  865.                         ENGLISH "bad function environment occurred in ~S: ~S"
  866.                         FRANCAIS "mauvais environnement de fonction dans ~S : ~S")
  867.                        '%expand-form *fenv*
  868.         ) ) )     )  )
  869.         (if (consp f)
  870.           (multiple-value-call #'%expand-cons form
  871.             (%expand-lambda f)
  872.             (%expand-list (rest form))
  873.           )
  874.           (error-of-type 'program-error
  875.             (DEUTSCH "~S: ~S ist keine korrekte Form"
  876.              ENGLISH "~S: invalid form ~S"
  877.              FRANCAIS "~ : forme Lisp incorrecte ~S")
  878.             '%expand-form form
  879. ) ) ) ) ) )
  880.  
  881. ; Nun die einzelnen Expander fⁿr die Special-forms:
  882.  
  883. ; RETURN-FROM, THE:
  884. ; 1. Argument lassen, alle weiteren expandieren
  885. (defun %expand-ab2 (form)
  886.   (multiple-value-call #'%expand-cons form
  887.       (first form) nil
  888.       (multiple-value-call #'%expand-cons (rest form)
  889.           (second form) nil
  890.           (%expand-list (cddr form))
  891. ) )   )
  892. (%put '%expand 'RETURN-FROM #'%expand-ab2)
  893. (%put '%expand 'THE #'%expand-ab2)
  894.  
  895. ; QUOTE, GO, DECLARE, LOAD-TIME-VALUE: nichts expandieren
  896. (let ((fun
  897.         (function %expand-quote/go/declare (lambda (form) (values form nil)))
  898.      ))
  899.   (%put '%expand 'QUOTE fun)
  900.   (%put '%expand 'GO fun)
  901.   (%put '%expand 'DECLARE fun)
  902.   (%put '%expand 'LOAD-TIME-VALUE fun)
  903. )
  904.  
  905. ; FUNCTION:
  906. ; Falls erstes bzw. zweites Argument Liste, als Lambda-Ausdruck expandieren.
  907. (%put '%expand 'FUNCTION
  908.   (function %expand-function
  909.     (lambda (form)
  910.       (multiple-value-call #'%expand-cons form
  911.           'FUNCTION nil
  912.           (if (atom (cddr form))
  913.             (if (function-name-p (second form))
  914.               (let ((h (fenv-assoc (second form) *fenv*)))
  915.                 (cond ((or (eq h 'T) (closurep h) (null h)) (values (rest form) nil))
  916.                       ((and (consp h) (eq (first h) 'MACRO))
  917.                        (error-of-type 'program-error
  918.                          (DEUTSCH "~S: ~S unzulΣssig, da ~S ein lokaler Macro ist"
  919.                           ENGLISH "~S: ~S is illegal since ~S is a local macro"
  920.                           FRANCAIS "~S : n'est pas permis car ~S est un macro local")
  921.                          '%expand form (second form)
  922.                       ))
  923.                       (t (error-of-type 'error
  924.                            (DEUTSCH "~S: Falscher Aufbau eines Function-Environment: ~S"
  925.                             ENGLISH "~S: invalid function environment ~S"
  926.                             FRANCAIS "~S : mauvais environnement de fonction ~S")
  927.                            '%expand *fenv*
  928.                       )  )
  929.               ) )
  930.               (if (atom (second form))
  931.                 (error-of-type 'program-error
  932.                   (DEUTSCH "~S: ~S unzulΣssig, da ~S kein Symbol"
  933.                    ENGLISH "~S: ~S is invalid since ~S is not a symbol"
  934.                    FRANCAIS "~S : ~S est inadmissible car ~S n'est pas un symbole")
  935.                   '%expand form (second form)
  936.                 )
  937.                 (multiple-value-call #'%expand-cons (rest form)
  938.                     (%expand-lambda (second form))
  939.                     (cddr form) nil
  940.             ) ) )
  941.             (multiple-value-call #'%expand-cons (rest form)
  942.                 (second form) nil
  943.                 (multiple-value-call #'%expand-cons (cddr form)
  944.                     (%expand-lambda (third form))
  945.                     (cdddr form) nil
  946.   ) ) )   ) )   )
  947. )
  948.  
  949. ; EVAL-WHEN:
  950. ; Falls die Situation COMPILE angegeben ist, fⁿhre den Body als PROGN aus,
  951. ;   gib eine Form zurⁿck, die ohne Seiteneffekte dieselben Werte liefert.
  952. ; Sonst expandiere alle Argumente ab dem zweiten als Formen.
  953. (%put '%expand 'EVAL-WHEN
  954.   (function %expand-eval-when
  955.     (lambda (form)
  956.       (if (member 'COMPILE (second form))
  957.         (values
  958.           (list 'values-list
  959.             (list 'quote
  960.               (multiple-value-list (eval (cons 'PROGN (cddr form))))
  961.           ) )
  962.           t
  963.         )
  964.         (%expand-ab2 form)
  965.   ) ) )
  966. )
  967.  
  968. ; LET: Variablenliste und Body expandieren
  969. (%put '%expand 'LET
  970.   (function %expand-let
  971.     (lambda (form)
  972.       (let ((*venv* *venv*))
  973.         (%expand-special-declarations (cddr form))
  974.         (multiple-value-call #'%expand-cons form
  975.           (first form) nil
  976.           (multiple-value-call #'%expand-cons (rest form)
  977.             (%expand-varspez (second form))
  978.             (%expand-list (cddr form))
  979.   ) ) ) ) )
  980. )
  981.  
  982. ; LET*: Variablenliste und Body expandieren
  983. (%put '%expand 'LET*
  984.   (function %expand-let*
  985.     (lambda (form)
  986.       (let ((*venv* *venv*))
  987.         (%expand-special-declarations (cddr form))
  988.         (multiple-value-call #'%expand-cons form
  989.           (first form) nil
  990.           (multiple-value-call #'%expand-cons (rest form)
  991.             (%expand-varspez* (second form))
  992.             (%expand-list (cddr form))
  993.   ) ) ) ) )
  994. )
  995.  
  996. ; LOCALLY: Body expandieren
  997. (%put '%expand 'LOCALLY
  998.   (function %expand-locally
  999.     (lambda (form)
  1000.       (let ((*venv* *venv*))
  1001.         (%expand-special-declarations (cdr form))
  1002.         (multiple-value-call #'%expand-cons form
  1003.           (first form) nil
  1004.           (%expand-list (cdr form))
  1005.   ) ) ) )
  1006. )
  1007.  
  1008. ; MULTIPLE-VALUE-BIND: Form und Body getrennt expandieren
  1009. (%put '%expand 'MULTIPLE-VALUE-BIND
  1010.   (function %expand-multiple-value-bind
  1011.     (lambda (form)
  1012.       (let ((*venv* *venv*))
  1013.         (%expand-special-declarations (cdddr form))
  1014.         (multiple-value-call #'%expand-cons form
  1015.           'MULTIPLE-VALUE-BIND nil
  1016.           (multiple-value-call #'%expand-cons (rest form)
  1017.             (second form) nil
  1018.             (multiple-value-call #'%expand-cons (cddr form)
  1019.               (%expand-form (third form))
  1020.               (progn
  1021.                 (%expand-lexical-variables (second form))
  1022.                 (%expand-list (cdddr form))
  1023.   ) ) ) ) ) ) )
  1024. )
  1025.  
  1026. ; COMPILER-LET: Variablenliste im leeren Environment und Body expandieren
  1027. (%put '%expand 'COMPILER-LET
  1028.   (function %expand-compiler-let
  1029.     (lambda (form)
  1030.       (progv
  1031.         (mapcar #'%expand-varspec-var (second form))
  1032.         (mapcar #'%expand-varspec-val (second form))
  1033.         (values (%expand-form (cons 'PROGN (cddr form))) t)
  1034.   ) ) )
  1035. )
  1036.  
  1037. ; COND: Alle Teilformen der Klauseln expandieren:
  1038. (%put '%expand 'cond
  1039.   (function %expand-cond
  1040.     (lambda (form)
  1041.       (multiple-value-call #'%expand-cons form
  1042.           (first form) nil
  1043.           (%expand-cond (rest form))
  1044.   ) ) )
  1045. )
  1046.  
  1047. ; BLOCK: Body expandieren. Falls darin ein RETURN-FROM auf diesen Block
  1048. ; vorkommt, behalte BLOCK. Sonst mache ein PROGN daraus.
  1049. (%put '%expand 'block
  1050.   (function %expand-block
  1051.     (lambda (form)
  1052.       (multiple-value-bind (body flagb) (%expand-list (cddr form))
  1053.         (if (%return-p (second form) body)
  1054.           (multiple-value-call #'%expand-cons form
  1055.               (first form) nil
  1056.               (multiple-value-call #'%expand-cons (rest form)
  1057.                   (second form) nil
  1058.                   body flagb
  1059.           )   )
  1060.           (values
  1061.             (cond ((atom body) body)
  1062.                   ((null (cdr body)) (car body))
  1063.                   (t (cons 'progn body))
  1064.             )
  1065.             t
  1066.   ) ) ) ) )
  1067. )
  1068.  
  1069. ; SETQ, PSETQ: jedes zweite Argument expandieren
  1070. (let ((fun
  1071.         (function %expand-setq/psetq
  1072.           (lambda (form)
  1073.             (if (%expand-setqlist-macrop (rest form))
  1074.               (let ((new (if (eq (first form) 'SETQ) 'SETF 'PSETF)))
  1075.                 (values
  1076.                   (%expand-form
  1077.                     (funcall (macro-function new) (cons new (rest form)) (vector *venv* *fenv*))
  1078.                   )
  1079.                   t
  1080.               ) )
  1081.               (multiple-value-call #'%expand-cons form
  1082.                 (first form) nil
  1083.                 (%expand-setqlist (rest form))
  1084.         ) ) ) )
  1085.      ))
  1086.   (%put '%expand 'SETQ fun)
  1087.   (%put '%expand 'PSETQ fun)
  1088. )
  1089.  
  1090. ; MULTIPLE-VALUE-SETQ : 1. Argument lassen, alle weiteren expandieren
  1091. (%put '%expand 'multiple-value-setq
  1092.   (function %expand-multiple-value-setq
  1093.     (lambda (form)
  1094.       (if (%expand-varlist-macrop (second form))
  1095.         (values (%expand-form (cons 'MULTIPLE-VALUE-SETF (rest form))) t)
  1096.         (%expand-ab2 form)
  1097.   ) ) )
  1098. )
  1099.  
  1100. ; TAGBODY: alle Argumente expandieren, dabei entstehende Atome weglassen
  1101. (%put '%expand 'tagbody
  1102.   (function %expand-tagbody
  1103.     (lambda (form)
  1104.       (multiple-value-call #'%expand-cons form
  1105.           (first form) nil
  1106.           (%expand-tagbody (rest form))
  1107.   ) ) )
  1108. )
  1109.  
  1110. ; PROGN: alle Argumente expandieren, evtl. vereinfachen.
  1111. (%put '%expand 'progn
  1112.   (function %expand-progn
  1113.     (lambda (form)
  1114.       (if (null (rest form))
  1115.         (values nil t)
  1116.         (if (null (cddr form))
  1117.           (values (%expand-form (second form)) t)
  1118.           (multiple-value-call #'%expand-cons form
  1119.               (first form) nil
  1120.               (%expand-list (rest form))
  1121.   ) ) ) ) )
  1122. )
  1123.  
  1124. ; FLET: Funktionsdefinitionen expandieren,
  1125. ; Body im erweiterten Environment expandieren
  1126. (%put '%expand 'flet
  1127.   (function %expand-flet
  1128.     (lambda (form)
  1129.       (if (null (second form))
  1130.         (values (%expand-form (cons 'PROGN (cddr form))) t)
  1131.         (let ((newfenv (%expand-fundefs-1 (second form))))
  1132.           (multiple-value-call #'%expand-cons form
  1133.             (car form) nil
  1134.             (multiple-value-call #'%expand-cons (cdr form)
  1135.               (%expand-fundefs-2 (second form))
  1136.               (let ((*fenv* (apply #'vector newfenv)))
  1137.                 (%expand-list (cddr form))
  1138.   ) ) ) ) ) ) )
  1139. )
  1140.  
  1141. ; LABELS: Funktionsdefinitionen und Body im erweiterten Environment expandieren
  1142. (%put '%expand 'labels
  1143.   (function %expand-labels
  1144.     (lambda (form)
  1145.       (if (null (second form))
  1146.         (values (%expand-form (cons 'PROGN (cddr form))) t)
  1147.         (let ((newfenv (%expand-fundefs-1 (second form))))
  1148.           (let ((*fenv* (apply #'vector newfenv)))
  1149.             (multiple-value-call #'%expand-cons form
  1150.               (car form) nil
  1151.               (multiple-value-call #'%expand-cons (cdr form)
  1152.                 (%expand-fundefs-2 (second form))
  1153.                 (%expand-list (cddr form))
  1154.   ) ) ) ) ) ) )
  1155. )
  1156.  
  1157. ; MACROLET: Body im erweiterten Environment expandieren
  1158. (%put '%expand 'macrolet
  1159.   (function %expand-macrolet
  1160.     (lambda (form)
  1161.       (do ((L1 (second form) (cdr L1))
  1162.            (L2 nil))
  1163.           ((atom L1)
  1164.            (if L1
  1165.              (error-of-type 'program-error
  1166.                (DEUTSCH "Dotted list im Code von MACROLET, endet mit ~S"
  1167.                 ENGLISH "code after MACROLET contains a dotted list, ending with ~S"
  1168.                 FRANCAIS "Le code de MACROLET contient une paire pointΘe, terminΘe par ~S")
  1169.                L1
  1170.              )
  1171.              (let ((*fenv* (apply #'vector (nreverse (cons *fenv* L2)))))
  1172.                (values (%expand-form (cons 'PROGN (cddr form))) t)
  1173.           )) )
  1174.         (let ((macrodef (car L1)))
  1175.           (if (and (consp macrodef) (symbolp (car macrodef)) (consp (cdr macrodef)))
  1176.             (setq L2
  1177.               (cons (make-macro-expandercons macrodef)
  1178.                     (cons (car macrodef) L2)
  1179.             ) )
  1180.             (error-of-type 'program-error
  1181.               (DEUTSCH "Falsche Syntax in MACROLET: ~S"
  1182.                ENGLISH "illegal syntax in MACROLET: ~S"
  1183.                FRANCAIS "syntaxe illΘgale dans MACROLET : ~S")
  1184.               macrodef
  1185.   ) ) ) ) ) )
  1186. )
  1187.  
  1188. ; SYMBOL-MACROLET: Body im erweiterten Environment expandieren
  1189. (%put '%expand 'symbol-macrolet
  1190.   (function %expand-symbol-macrolet
  1191.     (lambda (form)
  1192.       (do ((L1 (second form) (cdr L1))
  1193.            (L2 nil))
  1194.           ((atom L1)
  1195.            (if L1
  1196.              (error-of-type 'program-error
  1197.                (DEUTSCH "Dotted list im Code von SYMBOL-MACROLET, endet mit ~S"
  1198.                 ENGLISH "code after SYMBOL-MACROLET contains a dotted list, ending with ~S"
  1199.                 FRANCAIS "Le code de SYMBOL-MACROLET contient une paire pointΘe, terminΘe par ~S")
  1200.                L1
  1201.              )
  1202.              (let ((*venv* (apply #'vector (nreverse (cons *venv* L2)))))
  1203.                (values (%expand-form (cons 'LOCALLY (cddr form))) t)
  1204.           )) )
  1205.         (let ((symdef (car L1)))
  1206.           (if (and (consp symdef)
  1207.                    (symbolp (car symdef))
  1208.                    (consp (cdr symdef))
  1209.                    (null (cddr symdef))
  1210.               )
  1211.             (setq L2
  1212.               (cons (make-symbol-macro (cadr symdef)) (cons (car symdef) L2))
  1213.             )
  1214.             (error-of-type 'program-error
  1215.               (DEUTSCH "Falsche Syntax in SYMBOL-MACROLET: ~S"
  1216.                ENGLISH "illegal syntax in SYMBOL-MACROLET: ~S"
  1217.                FRANCAIS "syntaxe illΘgale dans SYMBOL-MACROLET : ~S")
  1218.               symdef
  1219.   ) ) ) ) ) )
  1220. )
  1221.  
  1222. ; %HANDLER-BIND: Handlerliste und Body expandieren
  1223. (%put '%expand '%handler-bind
  1224.   (function %expand-%handler-bind
  1225.     (lambda (form)
  1226.       (multiple-value-call #'%expand-cons form
  1227.         (first form) nil
  1228.         (multiple-value-call #'%expand-cons (rest form)
  1229.           (%expand-handlers (second form))
  1230.           (%expand-list (cddr form))
  1231.   ) ) ) )
  1232. )
  1233.  
  1234. )
  1235.  
  1236. ; Hilfsfunktionen fⁿr die Expansion:
  1237.  
  1238. ; expandiert eine Liste von Formen. 2 Werte.
  1239. (defun %expand-list (l)
  1240.   (if (atom l)
  1241.     (if l
  1242.       (error-of-type 'program-error
  1243.         (DEUTSCH "Dotted list im Code, endet mit ~S"
  1244.          ENGLISH "code contains a dotted list, ending with ~S"
  1245.          FRANCAIS "une paire pointΘe dans le code, terminΘe par ~S")
  1246.         l
  1247.       )
  1248.       (values nil nil)
  1249.     )
  1250.     (multiple-value-call #'%expand-cons l
  1251.                          (%expand-form (first l))
  1252.                          (%expand-list (rest l))
  1253. ) ) )
  1254.  
  1255. ; Fⁿgt lexikalische Variablen zu *venv* hinzu.
  1256. ; (Wird nur dazu benutzt, um Symbol-Macros zu ⁿberdecken.)
  1257. (defun %expand-lexical-variables (vars)
  1258.   (if vars
  1259.     (setq *venv*
  1260.       (apply #'vector
  1261.         (nconc (mapcan #'(lambda (v) (list v nil)) vars) (list *venv*))
  1262. ) ) ) )
  1263.  
  1264. ; Fⁿgt SPECIAL-Deklarationen am Anfang eines Body zu *venv* hinzu.
  1265. (defun %expand-special-declarations (body)
  1266.   (multiple-value-bind (body-rest declarations)
  1267.       (sys::parse-body body nil (vector *venv* *fenv*))
  1268.     (declare (ignore body-rest)) ; Deklarationen nicht wegwerfen!
  1269.     (let ((specials nil))
  1270.       (mapc #'(lambda (declspec)
  1271.                 (if (and (consp declspec) (null (cdr (last declspec))))
  1272.                   (if (eq (car declspec) 'SPECIAL)
  1273.                     (mapc #'(lambda (x) (if (symbolp x) (setq specials (cons x specials))))
  1274.                           (cdr declspec)
  1275.               ) ) ) )
  1276.             (nreverse declarations)
  1277.       )
  1278.       (%expand-lexical-variables (nreverse specials)) ; auf specdecl kommt es hier nicht an
  1279. ) ) )
  1280.  
  1281. ; expandiert einen Funktionsnamen, der ein Cons ist (das mu▀ ein
  1282. ; Lambda-Ausdruck sein). 2 Werte.
  1283. (defun %expand-lambda (l)
  1284.   (unless (eq (first l) 'lambda)
  1285.     (error-of-type 'program-error
  1286.       (DEUTSCH "~S: ~S sollte LAMBDA-Ausdruck sein"
  1287.        ENGLISH "~S: ~S should be a lambda expression"
  1288.        FRANCAIS "~S : ~S devrait Ωtre une expression LAMBDA")
  1289.       '%expand-form l
  1290.   ) )
  1291.   (multiple-value-call #'%expand-cons l
  1292.       'lambda nil ; LAMBDA
  1293.       (%expand-lambdabody (rest l))
  1294. ) )
  1295.  
  1296. ; expandiert den CDR eines Lambda-Ausdrucks, ein (lambdalist . body). 2 Werte.
  1297. (defun %expand-lambdabody (lambdabody)
  1298.   (let ((body (rest lambdabody)))
  1299.     (if (and (consp body)
  1300.              (let ((form (car body)))
  1301.                (and (consp form)
  1302.                     (eq (car form) 'DECLARE)
  1303.                     (let ((declspecs (cdr form)))
  1304.                       (and (consp declspecs)
  1305.                            (let ((declspec (car declspecs)))
  1306.                              (and (consp declspec)
  1307.                                   (eq (car declspec) 'SOURCE)
  1308.         )    ) )    ) )    ) )
  1309.       (values lambdabody nil) ; bereits expandiert -> unberⁿhrt lassen
  1310.       (let ((*venv* *venv*))
  1311.         (values (list*
  1312.                   (%expand-lambdalist (first lambdabody))
  1313.                   (list 'DECLARE (list 'SOURCE lambdabody))
  1314.                   (%expand-list (rest lambdabody))
  1315.                 )
  1316.                 t
  1317. ) ) ) ) )
  1318.  
  1319. ; expandiert eine Lambdaliste. 2 Werte.
  1320. (defun %expand-lambdalist (ll)
  1321.   (if (atom ll)
  1322.     (if ll
  1323.       (error-of-type 'program-error
  1324.         (DEUTSCH "Lambdaliste darf nicht mit dem Atom ~S enden"
  1325.          ENGLISH "lambda list must not end with the atom ~S"
  1326.          FRANCAIS "La liste lambda ne peut pas se terminer par l'atome ~S")
  1327.         ll
  1328.       )
  1329.       (values nil nil)
  1330.     )
  1331.     (multiple-value-call #'%expand-cons ll
  1332.         (%expand-parspez (first ll))
  1333.         (progn
  1334.           (let ((v (first ll)))
  1335.             (if (not (member v lambda-list-keywords :test #'eq))
  1336.               (setq *venv* (vector (%expand-varspec-var v) nil *venv*))
  1337.           ) )
  1338.           (%expand-lambdalist (rest ll))
  1339. ) ) )   )
  1340.  
  1341. ; expandiert ein Element einer Lambdaliste. 2 Werte.
  1342. ; (Expandiert dabei nur bei Listen, und dann auch nur das zweite Element.)
  1343. (defun %expand-parspez (ps)
  1344.   (if (or (atom ps) (atom (rest ps)))
  1345.     (values ps nil)
  1346.     (multiple-value-call #'%expand-cons ps
  1347.         (first ps) nil
  1348.         (multiple-value-call #'%expand-cons (rest ps)
  1349.             (%expand-form (second ps))
  1350.             (cddr ps) nil
  1351. ) ) )   )
  1352.  
  1353. ; expandiert eine Variablenliste fⁿr LET. 2 Werte.
  1354. (defun %expand-varspez (vs &optional (nvenv nil))
  1355.   (if (atom vs)
  1356.     (if vs
  1357.       (error-of-type 'program-error
  1358.         (DEUTSCH "~S: Variablenliste endet mit dem Atom ~S"
  1359.          ENGLISH "~S: variable list ends with the atom ~S"
  1360.          FRANCAIS "~S : La liste de variables se termine par l'atome ~S")
  1361.         'let vs
  1362.       )
  1363.       (progn
  1364.         (setq *venv* (apply #'vector (nreverse (cons *venv* nvenv))))
  1365.         (values nil nil)
  1366.     ) )
  1367.     (multiple-value-call #'%expand-cons vs
  1368.         (%expand-parspez (first vs)) ; Bei Liste 2. Element expandieren
  1369.         (%expand-varspez (rest vs) (list* nil (%expand-varspec-var (first vs)) nvenv))
  1370. ) ) )
  1371.  
  1372. ; expandiert eine Variablenliste fⁿr LET*. 2 Werte.
  1373. (defun %expand-varspez* (vs)
  1374.   (if (atom vs)
  1375.     (if vs
  1376.       (error-of-type 'program-error
  1377.         (DEUTSCH "~S: Variablenliste endet mit dem Atom ~S"
  1378.          ENGLISH "~S: variable list ends with the atom ~S"
  1379.          FRANCAIS "~S : La liste de variables se termine par l'atome ~S")
  1380.         'let* vs
  1381.       )
  1382.       (values nil nil)
  1383.     )
  1384.     (multiple-value-call #'%expand-cons vs
  1385.         (%expand-parspez (first vs)) ; Bei Liste 2. Element expandieren
  1386.         (progn
  1387.           (setq *venv* (vector (%expand-varspec-var (first vs)) nil *venv*))
  1388.           (%expand-varspez* (rest vs))
  1389. ) ) )   )
  1390.  
  1391. (defun %expand-varspec-var (varspec)
  1392.   (if (atom varspec) varspec (first varspec))
  1393. )
  1394.  
  1395. (defun %expand-varspec-val (varspec)
  1396.   (if (atom varspec) nil (eval (second varspec)))
  1397. )
  1398.  
  1399. ; Expandiert eine Cond-Klausel-Liste. 2 Werte.
  1400. (defun %expand-cond (clauses)
  1401.   (if (atom clauses)
  1402.     (values clauses nil)
  1403.     (multiple-value-call #'%expand-cons clauses
  1404.         (%expand-list (first clauses))
  1405.         (%expand-cond (rest clauses))
  1406. ) ) )
  1407.  
  1408. ; Auf den bereits expandierten Body wird folgendes angewandt:
  1409. ; (%return-p name list) stellt fest, ob die Formenliste list irgendwo ein
  1410. ; (RETURN-FROM name ...) enthΣlt.
  1411. (defun %return-p (name body)
  1412.   (block return-p
  1413.     (tagbody 1
  1414.       (if (atom body) (return-from return-p nil))
  1415.       (let ((form (car body)))
  1416.         (if
  1417.           ; stelle fest, ob form ein (RETURN-FROM name ...) enthΣlt:
  1418.           (and (consp form)
  1419.                (or (and (eq (first form) 'return-from) ; (RETURN-FROM name ...)
  1420.                         (eq (second form) name)
  1421.                    )
  1422.                    (and (consp (first form))           ; Lambdaliste
  1423.                         (%return-p name (first form))
  1424.                    )
  1425.                    (and (not ; keine neue Definition desselben Blocks ?
  1426.                           (and (eq (first form) 'block) (eq (second form) name))
  1427.                         )
  1428.                         (%return-p name (rest form)) ; Funktionsaufruf
  1429.           )    )   )
  1430.           (return-from return-p t)
  1431.       ) )
  1432.       (setq body (cdr body))
  1433.       (go 1)
  1434. ) ) )
  1435.  
  1436. (defun %expand-varlist-macrop (l)
  1437.   (and (consp l)
  1438.        (or (and (symbolp (car l)) (symbol-macro-p (venv-assoc (car l) *venv*)))
  1439.            (%expand-varlist-macrop (cdr l))
  1440. ) )    )
  1441.  
  1442. (defun %expand-setqlist-macrop (l)
  1443.   (and (consp l) (consp (cdr l))
  1444.        (or (and (symbolp (car l)) (symbol-macro-p (venv-assoc (car l) *venv*)))
  1445.            (%expand-setqlist-macrop (cddr l))
  1446. ) )    )
  1447.  
  1448. (defun %expand-setqlist (l)
  1449.   (if (or (atom l) (atom (cdr l)))
  1450.     (values l nil)
  1451.     (multiple-value-call #'%expand-cons l
  1452.         (first l) nil
  1453.         (multiple-value-call #'%expand-cons (rest l)
  1454.             (%expand-form (second l))
  1455.             (%expand-setqlist (cddr l))
  1456. ) ) )   )
  1457.  
  1458. ; (%expand-tagbody list) expandiert die Elemente einer Liste und lΣ▀t dabei
  1459. ; entstehende Atome fest (damit keine neuen Tags entstehen, die andere Tags
  1460. ; verdecken k÷nnten). 2 Werte.
  1461. (defun %expand-tagbody (body)
  1462.   (cond ((atom body) (values body nil))
  1463.         ((atom (first body))
  1464.          (multiple-value-call #'%expand-cons body
  1465.              (first body) nil
  1466.              (%expand-tagbody (rest body))
  1467.         ))
  1468.         (t (multiple-value-bind (exp flag) (%expand-form (first body))
  1469.              (if (atom exp)
  1470.                (values (%expand-tagbody (rest body)) t) ; weglassen
  1471.                (multiple-value-call #'%expand-cons body
  1472.                    exp flag
  1473.                    (%expand-tagbody (rest body))
  1474. ) )     )  ) ) )
  1475. ; (%expand-fundefs-1 fundefs) liefert eine Liste (name1 nil ... namek nil *fenv*)
  1476. (defun %expand-fundefs-1 (fundefs)
  1477.   (if (atom fundefs)
  1478.     (if fundefs
  1479.       (error-of-type 'program-error
  1480.         (DEUTSCH "FLET/LABELS: Dotted list im Code, endet mit ~S"
  1481.          ENGLISH "FLET/LABELS: code contains a dotted list, ending with ~S"
  1482.          FRANCAIS "FLET/LABELS : une paire pointΘe dans le code, terminΘe par ~S")
  1483.         fundefs
  1484.       )
  1485.       (list *fenv*)
  1486.     )
  1487.     (let ((fundef (car fundefs)))
  1488.       (if (and (consp fundef) (function-name-p (car fundef)) (consp (cdr fundef)))
  1489.         (list* (car fundef) nil (%expand-fundefs-1 (cdr fundefs)))
  1490.         (error-of-type 'program-error
  1491.           (DEUTSCH "Falsche Syntax in FLET/LABELS: ~S"
  1492.            ENGLISH "illegal syntax in FLET/LABELS: ~S"
  1493.            FRANCAIS "syntaxe incorrecte dans FLET/LABELS : ~S")
  1494.           fundef
  1495. ) ) ) ) )
  1496. ; (%expand-fundefs-2 fundefs) expandiert eine Funktionsdefinitionenliste,
  1497. ; wie in FLET, LABELS. 2 Werte.
  1498. (defun %expand-fundefs-2 (fundefs)
  1499.   (if (atom fundefs)
  1500.     (values fundefs nil)
  1501.     (let ((fundef (car fundefs)))
  1502.       (multiple-value-call #'%expand-cons fundefs
  1503.              (multiple-value-call #'%expand-cons fundef
  1504.                      (car fundef) nil
  1505.                      (%expand-lambdabody (cdr fundef))
  1506.              )
  1507.              (%expand-fundefs-2 (rest fundefs))
  1508. ) ) ) )
  1509. ; (%expand-handlers handlers) expandiert eine Typ/Handler-Liste
  1510. ; wie in %HANDLER-BIND. 2 Werte.
  1511. (defun %expand-handlers (handlers)
  1512.   (if (atom handlers)
  1513.     (values handlers nil)
  1514.     (let ((handler (car handlers)))
  1515.       (multiple-value-call #'%expand-cons handlers
  1516.         (multiple-value-call #'%expand-cons handler
  1517.           (car handler) nil
  1518.           (%expand-list (cdr handler))
  1519.         )
  1520.         (%expand-handlers (cdr handlers))
  1521. ) ) ) )
  1522.  
  1523. #|
  1524. ; expandiert eine Form in einem gegebenen Function-Environment
  1525. ; Kann bei Bedarf von EVAL aufgerufen werden.
  1526. (defun %expand-form-main (form *fenv*)
  1527.   (%expand-form form)
  1528. )
  1529. |#
  1530.  
  1531. ; expandiert (lambdalist . body) in einem gegebenen Function-Environment.
  1532. ; Wird von GET_CLOSURE aufgerufen.
  1533. (defun %expand-lambdabody-main (lambdabody *venv* *fenv*)
  1534.   (%expand-lambdabody lambdabody)
  1535. )
  1536.  
  1537. (VALUES) )
  1538.  
  1539. ;; ab hier ist FUNCTION funktionsfΣhig, soweit kein MACROLET darin vorkommt.
  1540.  
  1541. (PROGN
  1542.  
  1543. (proclaim '(special *load-paths*))
  1544. (setq *load-paths* nil)
  1545. (proclaim '(special *source-file-types*))
  1546. (setq *source-file-types* '(#".lsp"))
  1547. (proclaim '(special *compiled-file-types*))
  1548. (setq *compiled-file-types* '(#".fas"))
  1549.  
  1550. ; vorlΣufig brauchen die Files nicht gesucht zu werden:
  1551. (defun search-file (filename extensions)
  1552.   (mapcan #'(lambda (extension)
  1553.               (let ((filename (merge-pathnames filename extension)))
  1554.                 (if (probe-file filename) (list filename) '())
  1555.             ) )
  1556.           (reverse extensions)
  1557. ) )
  1558.  
  1559. (proclaim '(special *load-verbose*))
  1560. (setq *load-verbose* t)
  1561. (proclaim '(special *load-print*))
  1562. (setq *load-print* nil)
  1563. (proclaim '(special *load-echo*))
  1564. (setq *load-echo* nil)
  1565. (proclaim '(special *load-pathname*))
  1566. (setq *load-pathname* nil)
  1567. (proclaim '(special *load-truename*))
  1568. (setq *load-truename* nil)
  1569.  
  1570. ; (LOAD filename [:verbose] [:print] [:if-does-not-exist] [:echo] [:compiling]),
  1571. ; CLTL S. 426
  1572. (fmakunbound 'load)
  1573. (defun load (filename
  1574.              &key (verbose *load-verbose*) (print *load-print*) (if-does-not-exist t)
  1575.                   (echo *load-echo*) (compiling nil))
  1576.   (let ((stream
  1577.           (if (streamp filename)
  1578.             filename
  1579.             (or (open (setq filename (pathname filename))
  1580.                   :direction :input-immutable
  1581.                   :element-type 'string-char
  1582.                   :if-does-not-exist nil
  1583.                 )
  1584.                 ; Datei mit genau diesem Namen nicht vorhanden.
  1585.                 ; Suche unter den Dateien mit demselben Namen und den
  1586.                 ; Extensions "LSP", "FAS" die neueste:
  1587.                 (let ((present-files
  1588.                         (search-file filename
  1589.                           (append *source-file-types* *compiled-file-types*)
  1590.                      )) )
  1591.                   (if (endp present-files)
  1592.                     nil
  1593.                     (open (setq filename (first present-files))
  1594.                           :direction :input-immutable
  1595.                           :element-type 'string-char
  1596.        )) ) )   ) ) )
  1597.     (if stream
  1598.       (let ((input-stream
  1599.               (if echo
  1600.                 (make-echo-stream stream *standard-output*)
  1601.                 stream
  1602.             ) )
  1603.             ; :verbose, :print und :echo wirken nicht rekursiv - dazu
  1604.             ; hat man ja gerade die Special-Variablen *load-verbose* etc.
  1605.             ;(*load-verbose* verbose)
  1606.             ;(*load-print* print)
  1607.             ;(*load-echo* echo)
  1608.             (*load-pathname* (if (pathnamep filename) filename nil))
  1609.             (*load-truename* (if (pathnamep filename) (truename filename) nil))
  1610.             (*package* *package*) ; *PACKAGE* binden
  1611.             (*readtable* *readtable*) ; *READTABLE* binden
  1612.             (end-of-file "EOF")) ; einmaliges Objekt
  1613.         (when verbose
  1614.           (fresh-line)
  1615.           (write-string (DEUTSCH ";; Datei "
  1616.                          ENGLISH ";; Loading file "
  1617.                          FRANCAIS ";; Chargement du fichier ")
  1618.           )
  1619.           (princ filename)
  1620.           (write-string (DEUTSCH " wird geladen..."
  1621.                          ENGLISH " ..."
  1622.                          FRANCAIS " ...")
  1623.         ) )
  1624.         (block nil
  1625.           (unwind-protect
  1626.             (tagbody weiter
  1627.               (when echo (fresh-line))
  1628.               (let ((obj (read input-stream nil end-of-file)))
  1629.                 (when (eql obj end-of-file) (return-from nil))
  1630.                 (setq obj
  1631.                   (multiple-value-list
  1632.                     (cond ((compiled-function-p obj) (funcall obj))
  1633.                           (compiling (funcall (compile-form obj nil nil nil nil nil)))
  1634.                           (t (eval obj))
  1635.                 ) ) )
  1636.                 (when print (when obj (print (first obj))))
  1637.               )
  1638.               (go weiter)
  1639.             )
  1640.             (close stream) (close input-stream)
  1641.         ) )
  1642.         (when verbose
  1643.           (fresh-line)
  1644.           (write-string (DEUTSCH ";; Datei "
  1645.                          ENGLISH ";; Loading of file "
  1646.                          FRANCAIS ";; Le fichier ")
  1647.           )
  1648.           (princ filename)
  1649.           (write-string (DEUTSCH " ist geladen."
  1650.                          ENGLISH " is finished."
  1651.                          FRANCAIS " est chargΘ.")
  1652.         ) )
  1653.         t
  1654.       )
  1655.       (if if-does-not-exist
  1656.         (error-of-type 'file-error
  1657.           :pathname filename
  1658.           (DEUTSCH "Ein Datei mit Namen ~A gibt es nicht."
  1659.            ENGLISH "A file with name ~A does not exist"
  1660.            FRANCAIS "Il n'existe pas de fichier de nom ~A.")
  1661.           filename
  1662.         )
  1663.         nil
  1664.       )
  1665. ) ) )
  1666.  
  1667. ; vorlΣufig:
  1668. (sys::%putd 'defun
  1669.   (cons 'sys::macro
  1670.     (function defun
  1671.       (lambda (form env)
  1672.         (unless (and (consp (cdr form)) (consp (cddr form)))
  1673.           (error-of-type 'program-error
  1674.             (DEUTSCH "~S: Funktionsname und/oder Parameterliste fehlt"
  1675.              ENGLISH "~S: missing function name and/or parameter list"
  1676.              FRANCAIS "~S : Le nom de fonction et/ou la liste de paramΦtre manque")
  1677.             'defun
  1678.         ) )
  1679.         (let ((name (cadr form))
  1680.               (lambdalist (caddr form))
  1681.               (body (cdddr form)))
  1682.           (unless (symbolp name)
  1683.             (error-of-type 'program-error
  1684.               (DEUTSCH "~S: ~S ist kein Symbol."
  1685.                ENGLISH "~S: ~S is not a symbol."
  1686.                FRANCAIS "~S : ~S n'est pas un symbole.")
  1687.               'defun name
  1688.           ) )
  1689.           (when (special-form-p name)
  1690.             (error-of-type 'program-error
  1691.               (DEUTSCH "~S: Spezialform ~S kann nicht umdefiniert werden."
  1692.                ENGLISH "~S: special form ~S cannot be redefined."
  1693.                FRANCAIS "~S : La forme spΘciale ~S ne peut pas Ωtre redΘfinie.")
  1694.               'defun name
  1695.           ) )
  1696.           (multiple-value-bind (body-rest declarations docstring)
  1697.                                (sys::parse-body body t env)
  1698.             (declare (ignore docstring))
  1699.             #|
  1700.             `(PROGN
  1701.                (SYS::%PUT ',name 'SYS::DEFINITION
  1702.                  (CONS ',form (THE-ENVIRONMENT))
  1703.                )
  1704.                (SYS::%PUTD ',name
  1705.                  (FUNCTION ,name
  1706.                    (LAMBDA ,lambdalist
  1707.                      (DECLARE (SYS::IN-DEFUN ,name) ,@declarations)
  1708.                      (BLOCK ,name ,@body-rest)
  1709.                ) ) )
  1710.                ',name
  1711.              )
  1712.             |#
  1713.             (list 'progn
  1714.               (list 'sys::%put (list 'quote name) ''sys::definition
  1715.                     (list 'cons (list 'quote form) '(the-environment))
  1716.               )
  1717.               (list 'sys::%putd (list 'quote name)
  1718.                 (list 'FUNCTION name
  1719.                   (list 'LAMBDA lambdalist
  1720.                         (list* 'DECLARE (list 'SYS::IN-DEFUN name) declarations)
  1721.                         (list* 'BLOCK name body-rest)
  1722.               ) ) )
  1723.               (list 'quote name)
  1724.             )
  1725.     ) ) ) )
  1726. ) )
  1727.  
  1728. ; vorlΣufige Definition des Macros DO :
  1729. (sys::%putd 'do
  1730.   (cons 'sys::macro
  1731.     (function do
  1732.       (lambda (form env)
  1733.         (let ((varclauselist (second form))
  1734.               (exitclause (third form))
  1735.               (body (cdddr form)))
  1736.           (when (atom exitclause)
  1737.             (error-of-type 'program-error
  1738.               (DEUTSCH "Exitclause in ~S mu▀ Liste sein."
  1739.                ENGLISH "exit clause in ~S must be a list"
  1740.                FRANCAIS "La clause de sortie dans ~S doit Ωtre une liste.")
  1741.               'do
  1742.           ) )
  1743.           (let ((bindlist nil)
  1744.                 (reinitlist nil)
  1745.                 (bodytag (gensym))
  1746.                 (exittag (gensym)))
  1747.             (multiple-value-bind (body-rest declarations)
  1748.                                  (sys::parse-body body nil env)
  1749.               (block do
  1750.                 (tagbody 1
  1751.                   (when (atom varclauselist)
  1752.                     (return-from do
  1753.                       #|
  1754.                       `(block nil
  1755.                          (let ,(nreverse bindlist)
  1756.                            (declare ,@declarations)
  1757.                            (tagbody
  1758.                              (go ,exittag)
  1759.                              ,bodytag
  1760.                              ,@body-rest
  1761.                              (psetq ,@(nreverse reinitlist))
  1762.                              ,exittag
  1763.                              (or ,(first exitclause) (go ,bodytag))
  1764.                              (return-from nil (progn ,@(rest exitclause)))
  1765.                        ) ) )
  1766.                       |#
  1767.                       (list 'block 'nil
  1768.                         (list 'let (nreverse bindlist)
  1769.                           (cons 'declare declarations)
  1770.                           (list* 'tagbody
  1771.                             (list 'go exittag)
  1772.                             bodytag
  1773.                             (append body-rest
  1774.                               (list
  1775.                                 (cons 'psetq (nreverse reinitlist))
  1776.                                 exittag
  1777.                                 (list 'or (first exitclause) (list 'go bodytag))
  1778.                                 (list 'return-from 'nil
  1779.                                   (cons 'progn (rest exitclause))
  1780.                       ) ) ) ) ) )
  1781.                   ) )
  1782.                   (let ( (varclause (first varclauselist)) )
  1783.                        (setq varclauselist (rest varclauselist))
  1784.                        (cond ( (atom varclause)
  1785.                                   (setq bindlist
  1786.                                         (cons varclause bindlist)) )
  1787.                              ( (atom (cdr varclause))
  1788.                                   (setq bindlist
  1789.                                         (cons (first varclause) bindlist)) )
  1790.                              ( (atom (cddr varclause))
  1791.                                   (setq bindlist
  1792.                                         (cons varclause bindlist)) )
  1793.                              ( t (setq bindlist
  1794.                                        (cons (list (first varclause)
  1795.                                                    (second varclause))
  1796.                                              bindlist))
  1797.                                  (setq reinitlist
  1798.                                        (list* (third varclause)
  1799.                                               (first varclause)
  1800.                                               reinitlist)) )))
  1801.                   (go 1)
  1802.     ) ) ) ) ) ) )
  1803. ) )
  1804.  
  1805. ; vorlΣufige Definition des Macros DOTIMES :
  1806. (sys::%putd 'dotimes
  1807.   (cons 'sys::macro
  1808.     (function dotimes
  1809.       (lambda (form env)
  1810.         (let ((var (first (second form)))
  1811.               (countform (second (second form)))
  1812.               (resultform (third (second form)))
  1813.               (body (cddr form)))
  1814.           (multiple-value-bind (body-rest declarations)
  1815.                                (sys::parse-body body nil env)
  1816.             (let ((g (gensym)))
  1817.               #|
  1818.               `(DO ((,var 0 (1+ ,var))
  1819.                     (,g ,countform))
  1820.                    ((>= ,var ,g) ,resultform)
  1821.                  (declare ,@declarations)
  1822.                  ,@body-rest
  1823.                )
  1824.               |#
  1825.               (list* 'do (list (list var '0 (list '1+ var)) (list g countform))
  1826.                          (list (list '>= var g) resultform)
  1827.                      (cons 'declare declarations)
  1828.                      body-rest
  1829.               )
  1830.     ) ) ) ) )
  1831. ) )
  1832.  
  1833. (VALUES) )
  1834.  
  1835. ;; ab hier sind LOAD, DEFUN, DO, DOTIMES (eingeschrΣnkt) funktionsfΣhig.
  1836.  
  1837. (LOAD "defseq")   ;; Definitionen von Standard-Sequences
  1838.  
  1839. (LOAD "backquot") ;; Backquote-Readmacro
  1840.  
  1841. (PROGN
  1842.  
  1843. (sys::%putd 'sys::backquote
  1844.   (cons 'sys::macro
  1845.     (function sys::backquote
  1846.       (lambda (form &optional env) (declare (ignore env)) (third form))
  1847. ) ) )
  1848.  
  1849. (VALUES) )
  1850.  
  1851. ;; ab hier ist Backquote funktionsfΣhig
  1852.  
  1853. (LOAD "defmacro")
  1854.  
  1855. ;; ab hier ist FUNCTION (uneingeschrΣnkt) funktionsfΣhig.
  1856.  
  1857. (PROGN
  1858.  
  1859. (sys::%putd 'defmacro
  1860.   (cons 'sys::macro
  1861.     (function defmacro
  1862.       (lambda (form &optional env)
  1863.         (declare (ignore env))
  1864.         (multiple-value-bind (expansion name lambdalist docstring)
  1865.                              (sys::make-macro-expansion (cdr form))
  1866.           (declare (ignore lambdalist))
  1867.           `(LET ()
  1868.              (EVAL-WHEN (COMPILE LOAD EVAL)
  1869.                (SYSTEM::REMOVE-OLD-DEFINITIONS ',name)
  1870.                ,@(if docstring
  1871.                    `((SYSTEM::%SET-DOCUMENTATION ',name 'FUNCTION ',docstring))
  1872.                    '()
  1873.                  )
  1874.                (SYSTEM::%PUTD ',name (CONS 'SYSTEM::MACRO ,expansion))
  1875.              )
  1876.              (EVAL-WHEN (EVAL)
  1877.                (SYSTEM::%PUT ',name 'SYSTEM::DEFINITION
  1878.                  (CONS ',form (THE-ENVIRONMENT))
  1879.              ) )
  1880.              ',name
  1881.            )
  1882.     ) ) )
  1883. ) )
  1884.  
  1885. (sys::%putd 'defun
  1886.   (cons 'sys::macro
  1887.     (function defun
  1888.       (lambda (form env)
  1889.         (if (atom (cdr form))
  1890.           (error-of-type 'program-error
  1891.             (DEUTSCH "~S: Daraus kann keine Funktion definiert werden: ~S"
  1892.              ENGLISH "~S: cannot define a function from that: ~S"
  1893.              FRANCAIS "~S : Pas de dΘfinition de fonction possible α partir de: ~S")
  1894.             'defun (cdr form)
  1895.         ) )
  1896.         (unless (function-name-p (cadr form))
  1897.           (error-of-type 'program-error
  1898.             (DEUTSCH "~S: Der Name einer Funktion mu▀ ein Symbol sein, nicht: ~S"
  1899.              ENGLISH "~S: the name of a function must be a symbol, not ~S"
  1900.              FRANCAIS "~S : Le nom d'une fonction doit Ωtre un symbole et non ~S")
  1901.             'defun (cadr form)
  1902.         ) )
  1903.         (if (atom (cddr form))
  1904.           (error-of-type 'program-error
  1905.             (DEUTSCH "~S: Die Funktion ~S hat keine Lambdaliste."
  1906.              ENGLISH "~S: function ~S is missing a lambda list"
  1907.              FRANCAIS "~S : Il manque une liste lambda α la fonction ~S.")
  1908.             'defun (cadr form)
  1909.         ) )
  1910.         (let ((name (cadr form))
  1911.               (lambdalist (caddr form))
  1912.               (body (cdddr form)))
  1913.           (multiple-value-bind (body-rest declarations docstring)
  1914.                                (sys::parse-body body t env)
  1915.             (let ((symbolform
  1916.                     (if (atom name)
  1917.                       `',name
  1918.                       `(LOAD-TIME-VALUE (GET-SETF-SYMBOL ',(second name)))
  1919.                   ) )
  1920.                   (lambdabody
  1921.                     `(,lambdalist (DECLARE (SYS::IN-DEFUN ,name) ,@declarations)
  1922.                        (BLOCK ,(block-name name) ,@body-rest)
  1923.                      )
  1924.                  ))
  1925.               `(LET ()
  1926.                  (SYSTEM::REMOVE-OLD-DEFINITIONS ,symbolform)
  1927.                  ,@(if (and compiler::*compiling*
  1928.                             compiler::*compiling-from-file*
  1929.                             (member name compiler::*inline-functions* :test #'eq)
  1930.                             (null compiler::*venv*)
  1931.                             (null compiler::*fenv*)
  1932.                             (null compiler::*benv*)
  1933.                             (null compiler::*genv*)
  1934.                             (eql compiler::*denv* *toplevel-denv*)
  1935.                        )
  1936.                      ; Lambdabody fⁿr Inline-Compilation aufheben:
  1937.                      `((EVAL-WHEN (COMPILE)
  1938.                          (COMPILER::C-DEFUN ',name ',lambdabody)
  1939.                        )
  1940.                        (EVAL-WHEN (LOAD)
  1941.                          (SYSTEM::%PUT ,symbolform 'SYSTEM::INLINE-EXPANSION ',lambdabody)
  1942.                       ))
  1943.                      `((EVAL-WHEN (COMPILE) (COMPILER::C-DEFUN ',name)))
  1944.                    )
  1945.                  ,@(if docstring
  1946.                      `((SYSTEM::%SET-DOCUMENTATION ,symbolform 'FUNCTION ',docstring))
  1947.                      '()
  1948.                    )
  1949.                  (SYSTEM::%PUTD ,symbolform
  1950.                    (FUNCTION ,name (LAMBDA ,@lambdabody))
  1951.                  )
  1952.                  (EVAL-WHEN (EVAL)
  1953.                    (SYSTEM::%PUT ,symbolform 'SYSTEM::DEFINITION
  1954.                      (CONS ',form (THE-ENVIRONMENT))
  1955.                  ) )
  1956.                  ',name
  1957.                )
  1958.     ) ) ) ) )
  1959. ) )
  1960.  
  1961. (VALUES) )
  1962.  
  1963. ;; ab hier sind DEFMACRO und DEFUN funktionsfΣhig.
  1964.  
  1965. ; (MACRO-EXPANDER . macrodef)                                         [Macro]
  1966. ; expandiert zum Macro-Expander als Programmtext (FUNCTION ... (LAMBDA ...)).
  1967. (defmacro MACRO-EXPANDER (&body macrodef)
  1968.   (make-macro-expansion macrodef)
  1969. )
  1970.  
  1971. (LOAD "macros1")  ;; Kontrollstrukturen - Macros
  1972. (LOAD "macros2")  ;; weitere Macros
  1973.  
  1974. (LOAD "defs1")    ;; Definitionen zu Symbolen, Zahlen, Characters, Zeit
  1975. #-UNIX (LOAD "timezone") ;; Definition der Zeitzone
  1976.  
  1977. (LOAD "places")   ;; SETF-Places: Definitionen und Macros
  1978.  
  1979. ;; ab hier ist SETF u.Σ. funktionsfΣhig.
  1980.  
  1981. (LOAD "floatpri") ;; Ausgabe von Floating-Points
  1982.  
  1983. (LOAD "type")     ;; TYPEP
  1984.  
  1985. (LOAD "defstruc") ;; DEFSTRUCT-Macro
  1986.  
  1987. (LOAD "format")   ;; FORMAT
  1988.  
  1989. ; Ein Stⁿckchen "DO-WHAT-I-MEAN":
  1990. ; Sucht ein Programm-File.
  1991. ; Gesucht wird im aktuellen Directory und dann in den Directories
  1992. ; aus *load-paths*.
  1993. ; Ist eine Extension angegeben, so wird nur nach Files mit genau dieser
  1994. ; Extension gesucht. Ist keine Extension angegeben, so wird nur nach Files
  1995. ; mit einer Extension aus der gegebenen Liste gesucht.
  1996. ; Man erhΣlt alle Files aus dem ersten passenden Directory, als Pathnames,
  1997. ; in einer Liste, nach fallendem FILE-WRITE-DATE sortiert, oder NIL.
  1998. (defun search-file (filename extensions
  1999.                     &aux (use-extensions (null (pathname-type filename))) )
  2000.   (when use-extensions
  2001.     (setq extensions ; Case-Konversionen auf den Extensions durchfⁿhren
  2002.       (mapcar #'pathname-type extensions)
  2003.   ) )
  2004.   ; Defaults einmergen:
  2005.   (setq filename (merge-pathnames filename '#".*"))
  2006.   ; Suchen:
  2007.   (let ((already-searched nil))
  2008.     (dolist (dir (cons '#""
  2009.                        ; Wenn filename ".." enthΣlt, zΣhlt *load-paths* nicht
  2010.                        ; (um Errors wegen ".../../foo" z.B. auf DOS zu vermeiden):
  2011.                        (if (member #+(or ATARI DOS AMIGA ACORN-RISCOS) :PARENT
  2012.                                    #+(or UNIX OS/2) ".."
  2013.                                    (pathname-directory filename)
  2014.                                    :test #'equal
  2015.                            )
  2016.                          '()
  2017.                          (mapcar #'pathname *load-paths*)
  2018.             )    )     )
  2019.       (let ((search-filename
  2020.               (merge-pathnames (merge-pathnames filename dir))
  2021.            ))
  2022.         (unless (member search-filename already-searched :test #'equal)
  2023.           (let ((xpathnames (directory search-filename :full t :circle t)))
  2024.             (when use-extensions
  2025.               ; nach passenden Extensions filtern:
  2026.               (setq xpathnames
  2027.                 (delete-if-not ; hat xpathname eine der gegebenen Extensions?
  2028.                   #'(lambda (xpathname)
  2029.                       (member (pathname-type (first xpathname)) extensions
  2030.                               :test #-(or AMIGA OS/2) #'string=
  2031.                                     #+(or AMIGA OS/2) #'string-equal
  2032.                     ) )
  2033.                   xpathnames
  2034.             ) ) )
  2035.             (when xpathnames
  2036.               ; nach Datum sortiert, zurⁿckgeben:
  2037.               (dolist (xpathname xpathnames)
  2038.                 (setf (rest xpathname)
  2039.                       (apply #'encode-universal-time (third xpathname))
  2040.               ) )
  2041.               (return (mapcar #'first (sort xpathnames #'> :key #'rest)))
  2042.           ) )
  2043.           (push search-filename already-searched)
  2044.     ) ) )
  2045. ) )
  2046.  
  2047. (LOAD "user1")    ;; User-Interface, Teil 1: Break-Loop, Stepper
  2048.  
  2049. (LOAD "user2")    ;; User-Interface, Teil 2: Apropos, Describe, Dribble, Ed
  2050.  
  2051. (LOAD "trace")    ;; User-Interface, Teil 3: TRACE
  2052.  
  2053. ;(LOAD "macros3")  ;; weitere Macros, optional
  2054.  
  2055. (LOAD "config")   ;; Konfigurations-Parameter
  2056.  
  2057. (LOAD "compiler") ;; Compiler
  2058.  
  2059. (LOAD "defs2")    ;; CLtL2-Definitionen, optional
  2060.  
  2061. (LOAD "loop")     ;; CLtL2/dpANS-LOOP, optional
  2062.  
  2063. (LOAD "clos")     ;; CLOS, optional
  2064.  
  2065. (LOAD "conditio") ;; Conditions, optional
  2066.  
  2067. (LOAD "defs3")    ;; CLtL2-Definitionen, optional
  2068.  
  2069. (LOAD "gstream")  ;; generic streams, optional
  2070.  
  2071. #+UNIX (LOAD "foreign") ;; foreign function interface, optional
  2072.  
  2073. (when (or #+AMIGA t (find-package "SCREEN"))
  2074.   (LOAD "screen") ;; Screen-Paket, optional
  2075. )
  2076.  
  2077. (when (find-package "STDWIN")
  2078.   (LOAD "stdwin2") ;; STDWIN-Schnittstelle, optional
  2079. )
  2080.  
  2081. #+AMIGA (LOAD "rexx") ;; Rexx-Schnittstelle, optional
  2082.  
  2083. #+ATARI
  2084. (when (y-or-n-p (DEUTSCH "Editor laden?"
  2085.                  ENGLISH "Load editor?"
  2086.                  FRANCAIS "Charger l'Θditeur?")
  2087.       )
  2088.   (LOAD "editor") ;; Editor
  2089. )
  2090.  
  2091. (in-package "USER") ;; Default-Package aktuell machen
  2092.  
  2093.