summaryrefslogtreecommitdiff
path: root/scheme/chibi
diff options
context:
space:
mode:
authorLockywolf <lockywolf@gmail.com>2019-08-07 10:41:06 +0800
committerLockywolf <lockywolf@gmail.com>2019-08-07 10:41:06 +0800
commit2a2af730bdcc20e06755ac9e4cad5549e690cd6f (patch)
tree83cfaceafe063f13e10d36c98aa7fe2709c609c3 /scheme/chibi
parent8f801fbf01586e33bcf0060bd1d3172d4afb48cf (diff)
downloadgeiser-guile-2a2af730bdcc20e06755ac9e4cad5549e690cd6f.tar.gz
geiser-guile-2a2af730bdcc20e06755ac9e4cad5549e690cd6f.tar.bz2
Improve geiser:eval to return output Add docstring to geiser:output.
Diffstat (limited to 'scheme/chibi')
-rw-r--r--scheme/chibi/geiser/geiser.scm16
1 files changed, 12 insertions, 4 deletions
diff --git a/scheme/chibi/geiser/geiser.scm b/scheme/chibi/geiser/geiser.scm
index 94f745a..5f9e25e 100644
--- a/scheme/chibi/geiser/geiser.scm
+++ b/scheme/chibi/geiser/geiser.scm
@@ -19,14 +19,22 @@
(write form out)
(get-output-string out)))
+;;> Evaluate a \var{form} in the namespace of the \var{module}.
+;;> The meaning of \var{rest} is unknown.
+;;> Return the alist with the first field, \scheme{result}, holds
+;;> the result of evaluation \scheme{(write)}'d and the second
+;;> field, \scheme{output}, contains everyting that the evaluation
+;;> would print to the standard output.
+
(define (geiser:eval module form . rest)
rest
(guard (err (else (write `((result ,(show #f err))))))
- (let ((output (open-output-string))
- (result (if module
+ (let* ((output (open-output-string))
+ (result (parameterize ((current-output-port output))
+ (if module
(let ((mod (module-env (find-module module))))
(eval form mod))
- (eval form))))
+ (eval form)))))
(write `((result ,(write-to-string result))
(output . ,(get-output-string output))))))
(values))
@@ -95,7 +103,7 @@
#f)
;;> A chibi implementation of the standard geiser's location-making
-;;> subrouting. \var{file} is a string representing file name with path,
+;;> subroutine. \var{file} is a string representing file name with path,
;;> \var{line} is the line number starting from 0 (scheme way).
(define (make-location file line)