From 1180255e7b0e9e70a6d8b7665ac8a77886ef16a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C5=99emysl=20Janouch?= Date: Sat, 16 Apr 2016 23:44:52 +0200 Subject: [PATCH] calc: comment updates, import fixes --- plugins/zyklonb/calc | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/plugins/zyklonb/calc b/plugins/zyklonb/calc index e2f4be9..deea424 100755 --- a/plugins/zyklonb/calc +++ b/plugins/zyklonb/calc @@ -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->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>=? - 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))