Merge commit '202271f291971cf14175f5a1a193955f72d43d79' into vm-check
[bpt/guile.git] / module / language / r5rs / core.il
1 ;;; R5RS core environment
2
3 ;; Copyright (C) 2001 Free Software Foundation, Inc.
4
5 ;; This program is free software; you can redistribute it and/or modify
6 ;; it under the terms of the GNU General Public License as published by
7 ;; the Free Software Foundation; either version 2, or (at your option)
8 ;; any later version.
9 ;;
10 ;; This program is distributed in the hope that it will be useful,
11 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 ;; GNU General Public License for more details.
14 ;;
15 ;; You should have received a copy of the GNU General Public License
16 ;; along with this program; see the file COPYING. If not, write to
17 ;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 ;; Boston, MA 02111-1307, USA.
19
20 ;;; Code:
21
22 ;; Non standard procedures
23
24 (@define void (@lambda () (@void)))
25
26 ;; 6. Standard procedures
27
28 ;;; 6.1 Equivalence predicates
29
30 (@define eq? (@lambda (x y) (@eq? x y)))
31 (@define eqv? (@ Core::eqv?))
32 (@define equal? (@ Core::equal?))
33
34 ;;; 6.2 Numbers
35
36 (@define number? (@ Core::number?))
37 (@define complex? (@ Core::complex?))
38 (@define real? (@ Core::real?))
39 (@define rational? (@ Core::rational?))
40 (@define integer? (@ Core::integer?))
41
42 (@define exact? (@ Core::exact?))
43 (@define inexact? (@ Core::inexact?))
44
45 (@define = (@ Core::=))
46 (@define < (@ Core::<))
47 (@define > (@ Core::>))
48 (@define <= (@ Core::<=))
49 (@define >= (@ Core::>=))
50
51 (@define zero? (@ Core::zero?))
52 (@define positive? (@ Core::positive?))
53 (@define negative? (@ Core::negative?))
54 (@define odd? (@ Core::odd?))
55 (@define even? (@ Core::even?))
56
57 (@define max (@ Core::max))
58 (@define min (@ Core::min))
59
60 (@define + (@ Core::+))
61 (@define * (@ Core::*))
62 (@define - (@ Core::-))
63 (@define / (@ Core::/))
64
65 (@define abs (@ Core::abs))
66
67 (@define quotient (@ Core::quotient))
68 (@define remainder (@ Core::remainder))
69 (@define modulo (@ Core::modulo))
70
71 (@define gcd (@ Core::gcd))
72 (@define lcm (@ Core::lcm))
73
74 ;; (@define numerator (@ Core::numerator))
75 ;; (@define denominator (@ Core::denominator))
76
77 (@define floor (@ Core::floor))
78 (@define ceiling (@ Core::ceiling))
79 (@define truncate (@ Core::truncate))
80 (@define round (@ Core::round))
81
82 ;; (@define rationalize (@ Core::rationalize))
83
84 (@define exp (@ Core::exp))
85 (@define log (@ Core::log))
86 (@define sin (@ Core::sin))
87 (@define cos (@ Core::cos))
88 (@define tan (@ Core::tan))
89 (@define asin (@ Core::asin))
90 (@define acos (@ Core::acos))
91 (@define atan (@ Core::atan))
92
93 (@define sqrt (@ Core::sqrt))
94 (@define expt (@ Core::expt))
95
96 (@define make-rectangular (@ Core::make-rectangular))
97 (@define make-polar (@ Core::make-polar))
98 (@define real-part (@ Core::real-part))
99 (@define imag-part (@ Core::imag-part))
100 (@define magnitude (@ Core::magnitude))
101 (@define angle (@ Core::angle))
102
103 (@define exact->inexact (@ Core::exact->inexact))
104 (@define inexact->exact (@ Core::inexact->exact))
105
106 (@define number->string (@ Core::number->string))
107 (@define string->number (@ Core::string->number))
108
109 ;;; 6.3 Other data types
110
111 ;;;; 6.3.1 Booleans
112
113 (@define not (@lambda (x) (@not x)))
114 (@define boolean? (@ Core::boolean?))
115
116 ;;;; 6.3.2 Pairs and lists
117
118 (@define pair? (@lambda (x) (@pair? x)))
119 (@define cons (@lambda (x y) (@cons x y)))
120
121 (@define car (@lambda (x) (@car x)))
122 (@define cdr (@lambda (x) (@cdr x)))
123 (@define set-car! (@ Core::set-car!))
124 (@define set-cdr! (@ Core::set-cdr!))
125
126 (@define caar (@lambda (x) (@caar x)))
127 (@define cadr (@lambda (x) (@cadr x)))
128 (@define cdar (@lambda (x) (@cdar x)))
129 (@define cddr (@lambda (x) (@cddr x)))
130 (@define caaar (@lambda (x) (@caaar x)))
131 (@define caadr (@lambda (x) (@caadr x)))
132 (@define cadar (@lambda (x) (@cadar x)))
133 (@define caddr (@lambda (x) (@caddr x)))
134 (@define cdaar (@lambda (x) (@cdaar x)))
135 (@define cdadr (@lambda (x) (@cdadr x)))
136 (@define cddar (@lambda (x) (@cddar x)))
137 (@define cdddr (@lambda (x) (@cdddr x)))
138 (@define caaaar (@lambda (x) (@caaaar x)))
139 (@define caaadr (@lambda (x) (@caaadr x)))
140 (@define caadar (@lambda (x) (@caadar x)))
141 (@define caaddr (@lambda (x) (@caaddr x)))
142 (@define cadaar (@lambda (x) (@cadaar x)))
143 (@define cadadr (@lambda (x) (@cadadr x)))
144 (@define caddar (@lambda (x) (@caddar x)))
145 (@define cadddr (@lambda (x) (@cadddr x)))
146 (@define cdaaar (@lambda (x) (@cdaaar x)))
147 (@define cdaadr (@lambda (x) (@cdaadr x)))
148 (@define cdadar (@lambda (x) (@cdadar x)))
149 (@define cdaddr (@lambda (x) (@cdaddr x)))
150 (@define cddaar (@lambda (x) (@cddaar x)))
151 (@define cddadr (@lambda (x) (@cddadr x)))
152 (@define cdddar (@lambda (x) (@cdddar x)))
153 (@define cddddr (@lambda (x) (@cddddr x)))
154
155 (@define null? (@lambda (x) (@null? x)))
156 (@define list? (@lambda (x) (@list? x)))
157
158 (@define list (@lambda x x))
159
160 (@define length (@ Core::length))
161 (@define append (@ Core::append))
162 (@define reverse (@ Core::reverse))
163 (@define list-tail (@ Core::list-tail))
164 (@define list-ref (@ Core::list-ref))
165
166 (@define memq (@ Core::memq))
167 (@define memv (@ Core::memv))
168 (@define member (@ Core::member))
169
170 (@define assq (@ Core::assq))
171 (@define assv (@ Core::assv))
172 (@define assoc (@ Core::assoc))
173
174 ;;;; 6.3.3 Symbols
175
176 (@define symbol? (@ Core::symbol?))
177 (@define symbol->string (@ Core::symbol->string))
178 (@define string->symbol (@ Core::string->symbol))
179
180 ;;;; 6.3.4 Characters
181
182 (@define char? (@ Core::char?))
183 (@define char=? (@ Core::char=?))
184 (@define char<? (@ Core::char<?))
185 (@define char>? (@ Core::char>?))
186 (@define char<=? (@ Core::char<=?))
187 (@define char>=? (@ Core::char>=?))
188 (@define char-ci=? (@ Core::char-ci=?))
189 (@define char-ci<? (@ Core::char-ci<?))
190 (@define char-ci>? (@ Core::char-ci>?))
191 (@define char-ci<=? (@ Core::char-ci<=?))
192 (@define char-ci>=? (@ Core::char-ci>=?))
193 (@define char-alphabetic? (@ Core::char-alphabetic?))
194 (@define char-numeric? (@ Core::char-numeric?))
195 (@define char-whitespace? (@ Core::char-whitespace?))
196 (@define char-upper-case? (@ Core::char-upper-case?))
197 (@define char-lower-case? (@ Core::char-lower-case?))
198 (@define char->integer (@ Core::char->integer))
199 (@define integer->char (@ Core::integer->char))
200 (@define char-upcase (@ Core::char-upcase))
201 (@define char-downcase (@ Core::char-downcase))
202
203 ;;;; 6.3.5 Strings
204
205 (@define string? (@ Core::string?))
206 (@define make-string (@ Core::make-string))
207 (@define string (@ Core::string))
208 (@define string-length (@ Core::string-length))
209 (@define string-ref (@ Core::string-ref))
210 (@define string-set! (@ Core::string-set!))
211
212 (@define string=? (@ Core::string=?))
213 (@define string-ci=? (@ Core::string-ci=?))
214 (@define string<? (@ Core::string<?))
215 (@define string>? (@ Core::string>?))
216 (@define string<=? (@ Core::string<=?))
217 (@define string>=? (@ Core::string>=?))
218 (@define string-ci<? (@ Core::string-ci<?))
219 (@define string-ci>? (@ Core::string-ci>?))
220 (@define string-ci<=? (@ Core::string-ci<=?))
221 (@define string-ci>=? (@ Core::string-ci>=?))
222
223 (@define substring (@ Core::substring))
224 (@define string-append (@ Core::string-append))
225 (@define string->list (@ Core::string->list))
226 (@define list->string (@ Core::list->string))
227 (@define string-copy (@ Core::string-copy))
228 (@define string-fill! (@ Core::string-fill!))
229
230 ;;;; 6.3.6 Vectors
231
232 (@define vector? (@ Core::vector?))
233 (@define make-vector (@ Core::make-vector))
234 (@define vector (@ Core::vector))
235 (@define vector-length (@ Core::vector-length))
236 (@define vector-ref (@ Core::vector-ref))
237 (@define vector-set! (@ Core::vector-set!))
238 (@define vector->list (@ Core::vector->list))
239 (@define list->vector (@ Core::list->vector))
240 (@define vector-fill! (@ Core::vector-fill!))
241
242 ;;; 6.4 Control features
243
244 (@define procedure? (@ Core::procedure?))
245 (@define apply (@ Core::apply))
246 (@define map (@ Core::map))
247 (@define for-each (@ Core::for-each))
248 (@define force (@ Core::force))
249
250 (@define call-with-current-continuation (@ Core::call-with-current-continuation))
251 (@define values (@ Core::values))
252 (@define call-with-values (@ Core::call-with-values))
253 (@define dynamic-wind (@ Core::dynamic-wind))
254
255 ;;; 6.5 Eval
256
257 (@define eval
258 (@let ((l (@ Language::r5rs::spec::r5rs)))
259 (@lambda (x e)
260 (((@ System::Base::language::compile-in) x e l)))))
261
262 ;; (@define scheme-report-environment
263 ;; (@lambda (version)
264 ;; (@if (@= version 5)
265 ;; (@ Language::R5RS::Core)
266 ;; (@error "Unsupported environment version" version))))
267 ;;
268 ;; (@define null-environment
269 ;; (@lambda (version)
270 ;; (@if (@= version 5)
271 ;; (@ Language::R5RS::Null)
272 ;; (@error "Unsupported environment version" version))))
273
274 (@define interaction-environment (@lambda () (@current-module)))
275
276 ;;; 6.6 Input and output
277
278 ;;;; 6.6.1 Ports
279
280 (@define call-with-input-file (@ Core::call-with-input-file))
281 (@define call-with-output-file (@ Core::call-with-output-file))
282
283 (@define input-port? (@ Core::input-port?))
284 (@define output-port? (@ Core::output-port?))
285 (@define current-input-port (@ Core::current-input-port))
286 (@define current-output-port (@ Core::current-output-port))
287
288 (@define with-input-from-file (@ Core::with-input-from-file))
289 (@define with-output-to-file (@ Core::with-output-to-file))
290
291 (@define open-input-file (@ Core::open-input-file))
292 (@define open-output-file (@ Core::open-output-file))
293 (@define close-input-port (@ Core::close-input-port))
294 (@define close-output-port (@ Core::close-output-port))
295
296 ;;;; 6.6.2 Input
297
298 (@define read (@ Core::read))
299 (@define read-char (@ Core::read-char))
300 (@define peek-char (@ Core::peek-char))
301 (@define eof-object? (@ Core::eof-object?))
302 (@define char-ready? (@ Core::char-ready?))
303
304 ;;;; 6.6.3 Output
305
306 (@define write (@ Core::write))
307 (@define display (@ Core::display))
308 (@define newline (@ Core::newline))
309 (@define write-char (@ Core::write-char))
310
311 ;;;; 6.6.4 System interface
312
313 (@define load
314 (@lambda (file)
315 (call-with-input-file file
316 (@lambda (port)
317 (@let ((loop (@lambda (x)
318 (@if (@not (eof-object? x))
319 (@begin
320 (eval x (interaction-environment))
321 (loop (read port)))))))
322 (loop (read port)))))))
323
324 ;; transcript-on
325 ;; transcript-off