add env script
[bpt/guile.git] / module / slib / macscheme.init
1 ;;;"macscheme.init" Configuration of *features* for MacScheme -*-scheme-*-
2 ;;; Author: Aubrey Jaffer
3 ;;;
4 ;;; This code is in the public domain.
5
6 ;;; From: jjb@isye.gatech.edu (John Bartholdi)
7
8 ;;; (software-type) should be set to the generic operating system type.
9 ;;; UNIX, VMS, MACOS, AMIGA and MS-DOS are supported.
10
11 (define (software-type) 'MACOS)
12
13 ;;; (scheme-implementation-type) should return the name of the scheme
14 ;;; implementation loading this file.
15
16 (define (scheme-implementation-type) 'MacScheme)
17
18 ;;; (scheme-implementation-home-page) should return a (string) URI
19 ;;; (Uniform Resource Identifier) for this scheme implementation's home
20 ;;; page; or false if there isn't one.
21
22 (define (scheme-implementation-home-page) #f)
23
24 ;;; (scheme-implementation-version) should return a string describing
25 ;;; the version the scheme implementation loading this file.
26
27 (define (scheme-implementation-version) "4.2")
28
29 ;;; (implementation-vicinity) should be defined to be the pathname of
30 ;;; the directory where any auxillary files to your Scheme
31 ;;; implementation reside.
32
33 (define (implementation-vicinity) "Macintosh.HD:MacScheme 4.2:")
34
35 ;;; (library-vicinity) should be defined to be the pathname of the
36 ;;; directory where files of Scheme library functions reside.
37
38 (define (library-vicinity) "Macintosh.HD:MacScheme 4.2:slib:")
39
40 ;;; (home-vicinity) should return the vicinity of the user's HOME
41 ;;; directory, the directory which typically contains files which
42 ;;; customize a computer environment for a user.
43
44 (define (home-vicinity) #f)
45
46 ;;; *FEATURES* should be set to a list of symbols describing features
47 ;;; of this implementation. Suggestions for features are:
48
49 (define *features*
50 '(
51 source ;can load scheme source files
52 ;(slib:load-source "filename")
53 ; compiled ;can load compiled files
54 ;(slib:load-compiled "filename")
55 rev4-report ;conforms to
56 rev3-report ;conforms to
57 ieee-p1178 ;conforms to
58 ; sicp ;runs code from Structure and
59 ;Interpretation of Computer
60 ;Programs by Abelson and Sussman.
61 rev4-optional-procedures ;LIST-TAIL, STRING->LIST,
62 ;LIST->STRING, STRING-COPY,
63 ;STRING-FILL!, LIST->VECTOR,
64 ;VECTOR->LIST, and VECTOR-FILL!
65 rev3-procedures ;LAST-PAIR, T, and NIL
66 ; rev2-procedures ;SUBSTRING-MOVE-LEFT!,
67 ;SUBSTRING-MOVE-RIGHT!,
68 ;SUBSTRING-FILL!,
69 ;STRING-NULL?, APPEND!, 1+,
70 ;-1+, <?, <=?, =?, >?, >=?
71 multiarg/and- ;/ and - can take more than 2 args.
72 multiarg-apply ;APPLY can take more than 2 args.
73 rationalize
74 delay ;has DELAY and FORCE
75 with-file ;has WITH-INPUT-FROM-FILE and
76 ;WITH-OUTPUT-FROM-FILE
77 string-port ;has CALL-WITH-INPUT-STRING and
78 ;CALL-WITH-OUTPUT-STRING
79 ; transcript ;TRANSCRIPT-ON and TRANSCRIPT-OFF
80 ; char-ready?
81 ; macro ;has R4RS high level macros
82 ; defmacro ;has Common Lisp DEFMACRO
83 ; record ;has user defined data structures
84 ; values ;proposed multiple values
85 ; dynamic-wind ;proposed dynamic-wind
86 ieee-floating-point ;conforms to
87 full-continuation ;can return multiple times
88 ; object-hash ;has OBJECT-HASH
89
90 ; sort
91 ; queue ;queues
92 pretty-print
93 ; object->string
94 ; format
95 ; trace ;has macros: TRACE and UNTRACE
96 compiler ;has (COMPILER)
97 ; ed ;(ED) is editor
98 ; system ;posix (system <string>)
99 ; getenv ;posix (getenv <string>)
100 ; program-arguments ;returns list of strings (argv)
101 ; Xwindows ;X support
102 ; curses ;screen management package
103 ; termcap ;terminal description package
104 ; terminfo ;sysV terminal description
105 ))
106
107 ;;; (OUTPUT-PORT-WIDTH <port>)
108 (define (output-port-width . arg) 79)
109
110 ;;; (OUTPUT-PORT-HEIGHT <port>)
111 (define (output-port-height . arg) 24)
112
113 ;;; (CURRENT-ERROR-PORT)
114 (define current-error-port
115 (let ((port (current-output-port)))
116 (lambda () port)))
117
118 ;;; (TMPNAM) makes a temporary file name.
119 (define tmpnam (let ((cntr 100))
120 (lambda () (set! cntr (+ 1 cntr))
121 (string-append "slib_" (number->string cntr)))))
122
123 ;;; (FILE-EXISTS? <string>)
124 (define (file-exists? f) #f)
125
126 ;;; (DELETE-FILE <string>)
127 (define (delete-file f) #f)
128
129 ;;; FORCE-OUTPUT flushes any pending output on optional arg output port
130 ;;; use this definition if your system doesn't have such a procedure.
131 (define (force-output . arg) #t)
132
133 ;;; CALL-WITH-INPUT-STRING and CALL-WITH-OUTPUT-STRING are the string
134 ;;; port versions of CALL-WITH-*PUT-FILE.
135 (define (call-with-output-string f)
136 (let ((outsp (open-output-string)))
137 (f outsp)
138 (let ((s (get-output-string outsp)))
139 (close-output-port outsp)
140 s)))
141
142 (define (call-with-input-string s f)
143 (let* ((insp (open-input-string s))
144 (res (f insp)))
145 (close-input-port insp)
146 res))
147
148 ;;; "rationalize" adjunct procedures.
149 (define (find-ratio x e)
150 (let ((rat (rationalize x e)))
151 (list (numerator rat) (denominator rat))))
152 (define (find-ratio-between x y)
153 (find-ratio (/ (+ x y) 2) (/ (- x y) 2)))
154
155 ;;; CHAR-CODE-LIMIT is one greater than the largest integer which can
156 ;;; be returned by CHAR->INTEGER.
157 (define char-code-limit 256)
158
159 ;;; MOST-POSITIVE-FIXNUM is used in modular.scm
160 (define most-positive-fixnum 536870911)
161
162 ;;; Return argument
163 (define (identity x) x)
164
165 ;;; SLIB:EVAL is single argument eval using the top-level (user) environment.
166 (define slib:eval eval)
167
168 ;;; If your implementation provides R4RS macros:
169 ;(define macro:eval slib:eval)
170 ;(define macro:load load)
171
172 (define *defmacros*
173 (list (cons 'defmacro
174 (lambda (name parms . body)
175 `(set! *defmacros* (cons (cons ',name (lambda ,parms ,@body))
176 *defmacros*))))))
177 (define (defmacro? m) (and (assq m *defmacros*) #t))
178
179 (define (macroexpand-1 e)
180 (if (pair? e) (let ((a (car e)))
181 (cond ((symbol? a) (set! a (assq a *defmacros*))
182 (if a (apply (cdr a) (cdr e)) e))
183 (else e)))
184 e))
185
186 (define (macroexpand e)
187 (if (pair? e) (let ((a (car e)))
188 (cond ((symbol? a)
189 (set! a (assq a *defmacros*))
190 (if a (macroexpand (apply (cdr a) (cdr e))) e))
191 (else e)))
192 e))
193
194 (define gentemp
195 (let ((*gensym-counter* -1))
196 (lambda ()
197 (set! *gensym-counter* (+ *gensym-counter* 1))
198 (string->symbol
199 (string-append "slib:G" (number->string *gensym-counter*))))))
200
201 (define base:eval slib:eval)
202 (define (defmacro:eval x) (base:eval (defmacro:expand* x)))
203 (define (defmacro:expand* x)
204 (require 'defmacroexpand) (apply defmacro:expand* x '()))
205
206 (define (defmacro:load <pathname>)
207 (slib:eval-load <pathname> defmacro:eval))
208
209 (define (slib:eval-load <pathname> evl)
210 (if (not (file-exists? <pathname>))
211 (set! <pathname> (string-append <pathname> (scheme-file-suffix))))
212 (call-with-input-file <pathname>
213 (lambda (port)
214 (let ((old-load-pathname *load-pathname*))
215 (set! *load-pathname* <pathname>)
216 (do ((o (read port) (read port)))
217 ((eof-object? o))
218 (evl o))
219 (set! *load-pathname* old-load-pathname)))))
220
221 (define slib:warn
222 (lambda args
223 (let ((cep (current-error-port)))
224 (if (provided? 'trace) (print-call-stack cep))
225 (display "Warn: " cep)
226 (for-each (lambda (x) (display x cep)) args))))
227
228 ;;; define an error procedure for the library
229 (define slib:error
230 (lambda args
231 (if (provided? 'trace) (print-call-stack (current-error-port)))
232 (cerror "Error: " args)))
233
234 ;;; define these as appropriate for your system.
235 (define slib:tab #\tab)
236 (define slib:form-feed #\page)
237
238 ;;; Define these if your implementation's syntax can support it and if
239 ;;; they are not already defined.
240
241 ;(define (1+ n) (+ n 1))
242 ;(define (-1+ n) (+ n -1))
243 ;(define 1- -1+)
244
245 (define in-vicinity string-append)
246
247 ;;; Define SLIB:EXIT to be the implementation procedure to exit or
248 ;;; return if exitting not supported.
249 ; MacScheme does not return a value when it exits,
250 ; so simply invoke system procedure exit with 0 args.
251 (define slib:exit (lambda args (exit)))
252
253 ;;; Here for backward compatability
254 (define scheme-file-suffix
255 (let ((suffix (case (software-type)
256 ((NOSVE) "_scm")
257 (else ".scm"))))
258 (lambda () suffix)))
259
260 ;;; (SLIB:LOAD-SOURCE "foo") should load "foo.scm" or with whatever
261 ;;; suffix all the module files in SLIB have. See feature 'SOURCE.
262
263 ;(define slib:load-source load)
264 (define (slib:load-source f) (load (string-append f (scheme-file-suffix))))
265
266 ;;; (SLIB:LOAD-COMPILED "foo") should load the file that was produced
267 ;;; by compiling "foo.scm" if this implementation can compile files.
268 ;;; See feature 'COMPILED.
269
270 (define slib:load-compiled load)
271
272 ;;; At this point SLIB:LOAD must be able to load SLIB files.
273
274 (define slib:load slib:load-source)
275
276 (slib:load (in-vicinity (library-vicinity) "require"))