;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;; ;;;;;;;; ;;;;;; All files in this directory or any subdirectories are ;;;;;;;; ;;;;;; copyright 1997, 1998, 1999, 2000, 2002. ;;;;;;;; ;;;;;; by Rafael D. Sorkin. All rights reserved. ;;;;;;;; ;;;;;; ;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ~/lisp/preparations.gcl Time-stamp:<2002-Nov-28 17:30:35 15846.39179> ;======================================================================= ; General Preparations for Gnu Common Lisp (a flavor of TrueCommonLisp) ; (For elisp, use the file preparations.el) ;======================================================================= ; "User options" are flagged { ;! } ;======================================================================= ;: By default, we won't recompile the biblioteks (defvar recompile nil) ;; (setq recompile t) ;: Table of Contents ; ; Define some global constants and types not predefined by system ; Define some global variables ; Adjust various limits, options for printing and reading, etc ; Adjust compilation options if recompiling ; Define Infinity% and NaN% (if possible) ; Set the "load path" ; Load various libraries (with recompilation if requested) ; Initialize the random state ; Other ;---------------------------------------------------------------------- ;: Define some global constants and types not predefined by system ;---------------------------------------------------------------------- (progn (defconstant *lisp-type* 'gcl) ; gnu common lisp (defconstant *cmucl* nil) ; CMU Common Lisp (defconstant *CMUCL* nil) (defconstant *gcl* t) ; Gnu Common Lisp (defconstant *GCL* t) (defconstant *clisp* nil) ; CLISP (defconstant *sun-lisp* nil) ; Sun version of Lucid Lisp (defconstant *sunlisp* nil) (defconstant *SCL* nil) ; (defconstant *TCL* t) ; TCL = True Common Lisp (defconstant *tcl* t) (defconstant *elisp* nil) ; Emacs Lisp ;; Not working: just returns the exit status 0, not the name! ;; so for now just make it be a dummy ;;;(defconstant *hostname* (system "hostname")) (defvar *hostname* "nani?") (defconstant otherwise t "for use in ``otherwise'' clause of `cond' etc.") (defconstant else t "for use in ``otherwise'' clause of `cond' etc.") (defconstant float-epsilon (* 2 DOUBLE-FLOAT-EPSILON) "\ Some estimate of the precision of a floating point number. The name `float-epsilon' is copied from the CL extension of elisp. ") ; ; Something like the smallest number you can add to 1.0 without changing it. ; We double DOUBLE-FLOAT-EPSILON to make it agree with elisp's ; `float-epsilon' for double precision numbers ;; Following not really needed for gcl, one would hope. ;; however must keep it for now, because various fcns refer to *float* and ;; maybe also `realfloat' ;; See comments in ~/lisp/3:COMMENTS on this mess (deftype realfloat () " The type we wish were always the default float" 'double-float) (defconstant *float* 'realfloat "\ This is supposed to be the default float type, defined this way only for elisp compatibility (though we need realfloat only for TCL!)") "Some global constants and types defined") ;------------------------------ ;: Define some global variables ;------------------------------ (progn (defvar *carefully* t "\ When true, makes various functions operate with more checking: poset functions may check for transitivity or sorting, matrix multiplication may check that dimensions of factors match, etcetera.") ; ; Note: the default value will not override a value the vble has already (defvar *mrv* nil " Place to deposit multiple return values") (declaim (special *mrv*)) ; is this needed? " Defined some global variables ") ;-------------------------------------------------------------- ;: Adjust various limits, options for printing and reading, etc ;-------------------------------------------------------------- ;:: (See preparations.cmucl for further examples.) ;:: raise limit on number of function arguments? ;; important on is probably first (eg to allow (apply 'max LIST)) ; (setq call-arguments-limit 8192) ; or nil? or still bigger? ; (setq lambda-parameters-limit 8192) ; or nil? or still bigger? ;:: commented out ;;(setq *read-default-float-format* 'DOUBLE-FLOAT) ; ; This tries to make the reader read things like 3.4 or 1e56 as double floats ; Doesn't seem to be needed for gcl, thankfully ;:: Raise garbage collection threshold? ;; can this even be done in gcl? ;:: Raise memory limits? (any relevance to gcl?) ;------------------- ;:: printing options ;------------------- ; Many of the following just reiterate the defaults (progn (setq *print-case* :downcase) ; symbols print in lower case ; default is :upcase (setq *print-length* 17) ; number of data object elements that ; will be printed (nil=unlimited) (setq *print-level* nil) ; controls depth of printing, ; nil means no limit '(setq *print-circle* t) ; allows circular lists to print ; (but alters how some lists print that ; share tissue) ; ;;; For now we omit this because it causes an error in printing long lists ;; (even if *print-length* is small) !! ;; namely "value stack overflow" ;; (but without it we get OTHER printing errors: loops! achhh) (setq *print-escape* t) ; causes printed rep to carry fuller ; information (a la `prin1' vs ; `princ'). In particular, will use ; #-notation in printing uninterned ; symbols if *print-gensym* is also ; true. (setq *print-gensym* t) (setq *print-pretty* t) ; makes arrays etc print nicer (but ; they take more space) (setq *print-array* t) ; makes vectors print intelligibly (setq SYSTEM:*PRINT-NANS* t) ; can't find documentation for this variable, ; but doing this allows NaN and Infinity to be ; printed (see ~/lisp/TCL/bug.NaN.gcl) " various printing options adjusted") ;------------------------------------------- ;: Adjust compilation options if recompiling ;------------------------------------------- ;;; Does following do anything? (when recompile (declaim (optimize ;! ;; (Safety 3) ;! (Speed 3) (Safety 0) ;! (Space 0) ;! (Compilation-speed 0)))) ;! ; Here is default provided by gcl ; OPTIMIZE levels: Safety=0 (No runtime error checking), Space=0, Speed=3 ; (when recompile ; (proclaim ; '(optimize ;------------------------------------------------- ;: Define Infinity% and NaN% (if possible) ;------------------------------------------------- ; All other numerical constants are loaded from bibliotek.constants.l ; ;; This is so far for GCL running on phonon ;; First concoct what we think are Infinity and NaN (making latter from former) ;; ;; We use defvar to avoid bug in gcl (see ~/lisp/TCL/bug.NaN.gcl) (defvar Infinity% (* 1.5e308 1.5e308) "The ``infinite number''") (defvar Infinity Infinity% "The ``infinite number''") (defvar -Infinity% (- Infinity%) "The negatively ``infinite number''") (defvar NaN% (- Infinity% Infinity%) "``Not a Number''") (defvar NaN NaN% "``Not a Number''") ; (defconstant Infinity% (* 1.5e308 1.5e308) "The ``infinite number''") ; (defconstant Infinity Infinity% "The ``infinite number''") ; (defconstant -Infinity% (- Infinity%) "The negatively ``infinite number''") ; (defconstant NaN% (- Infinity% Infinity%) "``Not a Number''") ; (defconstant NaN NaN%) ;; Now test for them really being +Infinity and NaN (cond ((and (numberp NaN) (numberp Infinity) ;------------------------------ ; we don't do following for now ; for some reason gcl thinks NaN < 0 ! ; evaluate `(= NaN 0)' ;------------------------------ ;; (not (or (< NaN 0) (= NaN 0) (> NaN 0))) (= Infinity (+ Infinity Infinity)) (/= Infinity 0) (> Infinity 0)) ;------------------ ; report success ;------------------ (princ "Infinity% and NaN% defined successfully.")(terpri)) ;------------------------------------- ;/take remedial action if they weren't ;------------------------------------- (t (print (format nil " Infinity and NaN came out WRONG: Infinity => ~s and NaN => ~s." Infinity% NaN%)))) ; ; Notes ; ; Apparently, one NaN need not be equal (or = or eql or equalp) to another! ; ; Infinity and NaN% are lisp "numbers" (numberp=t) ;; In case above doesn't work, here's a fallback ; ; (defconstant Infinity% 'Inf_symbol) ; (defconstant -Infinity% '-Inf_symbol) ; (defconstant NaN% 'NaN_symbol) ; (defconstant Infinity Infinity%) ; (defconstant NaN NaN%) ; (princ ; " Both Infinity and NaN have been made symbols (rather than IEEE floats)") ;------------------------------------------------------------------------- ;: Set the "load path" (would that a real load path existed!) ;------------------------------------------------------------------------- (defvar *lisp-home* nil "The home directory for all these files") (defvar lisp-home-relative-to-home-dir nil "The *lisp-home* directory specified relative to your home directory") (setq lisp-home-relative-to-home-dir "lisp/") ;! ; ; This specifies the home directory for all these files. ; Notice the trailing slash, it is is essential! (setq *lisp-home* (concatenate 'string (namestring (user-homedir-pathname nil)) lisp-home-relative-to-home-dir)) ;; (setq *lisp-home* "/home1/sorkin/lisp/") ;! ; ; This is a simpler form, but it can only be used if you change it by ; hand for each different machine (setq *default-pathname-defaults* (pathname *lisp-home*)) ;; The above mishagas is partly because somehow *default-pathname-defaults* ;; keeps getting reset to the empty string (or more precisely the empty ;; pathname)!!! (This seemed to happen when "require", not when "load") ;; Note that we are not truly setting a "load path", but rather influencing the ;; default initial segment for a pathname. Can GCL actually have a proper ;; "load path" like emacs? ie can we specify a _list_of_paths_ to try? ;---------------------------------------------------------- ;: Load various libraries (with recompilation if requested) ;---------------------------------------------------------- (when recompile (load "bibliotek.TCL.l") (load "bibliotek.gcl.l") (load "bibliotek.macros.l") (load "bibliotek.constants.l") (load "bibliotek.general.l") (load "bibliotek.general.tcl.l") (load "bibliotek.general.gcl.l") (load "bibliotek.poset.l") (load "bibliotek.float.l") (load "bibliotek.extras.l") (compile-file (format nil "~A~A" *lisp-home* "bibliotek.TCL.l")) (compile-file (format nil "~A~A" *lisp-home* "bibliotek.gcl.l")) (compile-file (format nil "~A~A" *lisp-home* "bibliotek.macros.l")) (compile-file (format nil "~A~A" *lisp-home* "bibliotek.constants.l")) (compile-file (format nil "~A~A" *lisp-home* "bibliotek.general.l")) (compile-file (format nil "~A~A" *lisp-home* "bibliotek.general.tcl.l")) (compile-file (format nil "~A~A" *lisp-home* "bibliotek.general.gcl.l")) (compile-file (format nil "~A~A" *lisp-home* "bibliotek.poset.l")) (compile-file (format nil "~A~A" *lisp-home* "bibliotek.float.l")) (compile-file (format nil "~A~A" *lisp-home* "bibliotek.extras.l")) ; Use following style if above doesn't work ; ; (compile-file (concatenate 'string *lisp-home* "bibliotek.macros.el")) ; (compile-file (concatenate 'string *lisp-home* "bibliotek.poset.el")) ; This is another style but messes up when *default-pathname-defaults* gets ; mysteriously reset ; (compile-file (merge-pathnames "bibliotek.TCL.l")) (princ "Ten bibliotek's loaded and compiled")(terpri)) (progn (load "bibliotek.TCL.o") (load "bibliotek.gcl.o") (load "bibliotek.macros.o") (load "bibliotek.constants.o") (load "bibliotek.general.o") (load "bibliotek.general.tcl.o") (load "bibliotek.general.gcl.o") (load "bibliotek.poset.o") (load "bibliotek.float.o") (load "bibliotek.extras.o") (princ "Ten compiled biblioteks loaded")(terpri)) ; For some reason, the syntax used above for `load' doesn't work for ; `compile-file'. Apparently, dieser can't handle the relative path names. ; Hence we use `merge-pathnames', which interprets the pathname by comparing ; with `*default-pathname-defaults*' ;------------------------------------------------- ;: Initialize the random state to a "random" value ;------------------------------------------------- (setq *random-state* (make-random-state t)) (princ "Random number generator initialized ``randomly''.") ;-------------------------------------------------------- ;: Other ;-------------------------------------------------------- (setq recompile nil) (assert (and (eq 0 0) (eq 1 1) (eq 2 2) (eq 3 3))) ; ; In some places we assume that this is true. Unfortunately success of this ; "assertion" doesn't really prove it. (provide 'preparations) (terpri) (princ "============================================") (terpri) ;: e n d