[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/geiser-chez 1bb0a87 06/37: Handle exceptions of ChezScheme
From: |
Philip Kaludercic |
Subject: |
[nongnu] elpa/geiser-chez 1bb0a87 06/37: Handle exceptions of ChezScheme and multi-value as well |
Date: |
Sun, 1 Aug 2021 18:25:55 -0400 (EDT) |
branch: elpa/geiser-chez
commit 1bb0a878513ffeac666205b96b92174323322eae
Author: Chaos Eternal <chaos@shlug.org>
Commit: Chaos Eternal <chaos@shlug.org>
Handle exceptions of ChezScheme and multi-value as well
- Capture exceptions of ChezScheme
- handles multi-value return
---
scheme/chez/geiser/geiser.ss | 31 +++++++++++++++++++++++++++----
1 file changed, 27 insertions(+), 4 deletions(-)
diff --git a/scheme/chez/geiser/geiser.ss b/scheme/chez/geiser/geiser.ss
index 2fa648c..6568120 100644
--- a/scheme/chez/geiser/geiser.ss
+++ b/scheme/chez/geiser/geiser.ss
@@ -30,11 +30,34 @@
(define (geiser:eval module form . rest)
rest
- (let ((result (if module
- (eval form (environment module))
- (eval form))))
+ (let* ((try-eval (lambda (x . y)
+ (call/cc
+ (lambda (k)
+ (with-exception-handler
+ (lambda (e)
+ (k e))
+ (lambda ()
+ (if (null? y) (eval x)
+ (eval x (car y)))
+ ))))))
+ (result-mid (call-with-values
+ (lambda () (if module
+ (try-eval form (environment module))
+ (try-eval form)))
+ (lambda (x . y)
+ (if (null? y)
+ x
+ (cons x y)))))
+ (result result-mid)
+ (error (if (condition? result-mid)
+ (cons 'error (list
+ (cons 'key
+ (with-output-to-string
+ (lambda () (display-condition
result-mid))))))
+ '())))
(write `((result ,(write-to-string result))
- (output . "")))
+ (output . "")
+ ,error))
(newline)))
(define (geiser:module-completions prefix . rest)
- [nongnu] branch elpa/geiser-chez created (now 03da1c1), Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-chez 2a7a3f6 01/37: Add preliminary support for Chez Scheme, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-chez 1f1ee00 02/37: Clean-up elisp code, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-chez 1bb0a87 06/37: Handle exceptions of ChezScheme and multi-value as well,
Philip Kaludercic <=
- [nongnu] elpa/geiser-chez 993b630 07/37: Alway pretty-print for results, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-chez ab13b7f 03/37: Chez: add rudimentary autodoc support, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-chez e4c15a7 04/37: fix call the chez scheme executable., Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-chez 6a83bee 08/37: rewritten geiser:eval to fix the following bug:, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-chez 2fb484b 05/37: Use (car (process-lines ...)) instead of (shell-command ...), Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-chez a5a6176 11/37: fix compile and load for chez, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-chez 2d682c0 13/37: fix for geiser-chez-parameters, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-chez 7bc8f62 14/37: Capture stdout in ChezScheme's eval:geiser, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-chez 352515c 16/37: Begin the summary lines of all elisp libraries with three semicolons, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-chez a0f6fc3 15/37: Add rudimentary Chez support for macro expansion, Philip Kaludercic, 2021/08/01