calc: comment updates, import fixes

This commit is contained in:
Přemysl Eric Janouch 2016-04-16 23:44:52 +02:00
parent 6f85490fa3
commit 1180255e7b

View File

@ -93,7 +93,10 @@
; --- Calculator ---------------------------------------------------------------
; Evaluator derived from the example in The Scheme Programming Language
; Evaluator derived from the example in The Scheme Programming Language.
;
; Even though EVAL with a carefully crafted environment would also do a good
; job at sandboxing, it would probably be impossible to limit execution time...
(define (env-new formals actuals env)
(cond [(null? formals) env]
@ -108,7 +111,8 @@
(error 'check-reductions "reduction limit exceeded")
(set-car! r (- (car r) 1))))
; TODO - think about implementing more syntactical constructs
; TODO - think about implementing more syntactical constructs,
; however there's not much point in having anything else in a calculator...
(define (exec expr r env)
(check-reductions r)
(cond [(symbol? expr) (env-lookup expr env)]
@ -135,6 +139,7 @@
[(_) '()]
[(_ a b ...) (cons (cons (quote a) a) (forward b ...))]))
; ...which can't prevent me from simply importing most of the standard library
(define base-library
(forward
; Equivalence, procedure predicate, booleans
@ -158,12 +163,12 @@
symbol? symbol=? symbol->string string->symbol
; Characters
char? char=? char<? char>? char<=? char>=? char->integer integer->char
; Strings; XXX make-string can make an arbitrary length string -> removed
; Strings; XXX - omitted make-string - can cause OOM
string? string=? string<? string>? string<=? string>=?
make-string string string-length string-ref substring
string string-length string-ref substring
string-append string->list list->string string-for-each string-copy
; Vectors; XXX make-vector can make an arbitrary length vectors -> removed
vector? make-vector vector vector-length vector-ref vector-set!
; Vectors; XXX - omitted make-vector - can cause OOM
vector? vector vector-length vector-ref vector-set!
vector->list list->vector vector-fill! vector-map vector-for-each
; Control features
apply call/cc values call-with-values dynamic-wind))