diff options
author | Chaos Eternal <chaos@shlug.org> | 2017-08-24 18:54:20 +0800 |
---|---|---|
committer | Chaos Eternal <chaos@shlug.org> | 2017-08-27 15:03:43 +0800 |
commit | c8caccbadb56fd20ac77d770b03bbe2307014038 (patch) | |
tree | 05e301164cd867f5f8a89ab029d3440d312aee53 /scheme/chez/geiser/geiser.ss | |
parent | 2e880649e4d59346585a5739041822b0c17802d0 (diff) | |
download | geiser-guile-c8caccbadb56fd20ac77d770b03bbe2307014038.tar.gz geiser-guile-c8caccbadb56fd20ac77d770b03bbe2307014038.tar.bz2 |
more reduction on geiser:eval, add test
Diffstat (limited to 'scheme/chez/geiser/geiser.ss')
-rw-r--r-- | scheme/chez/geiser/geiser.ss | 58 |
1 files changed, 27 insertions, 31 deletions
diff --git a/scheme/chez/geiser/geiser.ss b/scheme/chez/geiser/geiser.ss index ca50295..8b9aba7 100644 --- a/scheme/chez/geiser/geiser.ss +++ b/scheme/chez/geiser/geiser.ss @@ -34,37 +34,33 @@ (if module (eval form (environment module)) (eval form)))) - (result-mid (call-with-values - (lambda () - (call/cc - (lambda (k) - (with-exception-handler - (lambda (e) - (k 'error e)) - (lambda () - (call-with-values - (lambda () - (body)) - (lambda (x . y) - (if (null? y) - (k 'single x) - (k 'multi (cons x y)))))))))) - (lambda (t v) - (cons t v)))) - (result (if (eq? (car result-mid) 'error) - "" - (with-output-to-string - (lambda () - (pretty-print (cdr result-mid)))))) - (error (if (eq? (car result-mid) 'error) - (cons 'error (list - (cons 'key - (with-output-to-string - (lambda () (display-condition (cdr result-mid))))))) - '()))) - (write `((result ,result) - (output . "") - ,error)) + (gen-result (lambda (result-mid is-error?) + (if is-error? + `((result "") + (output . "") + (error . ,(list + (cons 'key + (with-output-to-string + (lambda () + (display-condition result-mid))))))) + `((result ,(with-output-to-string + (lambda () + (pretty-print result-mid)))) + (output . ""))))) + (result (call/cc + (lambda (k) + (with-exception-handler + (lambda (e) + (k (gen-result e #t))) + (lambda () + (call-with-values + (lambda () + (body)) + (lambda (x . y) + (if (null? y) + (k (gen-result x #f)) + (k (gen-result (cons x y) #f))))))))))) + (write result) (newline))) (define (geiser:module-completions prefix . rest) |