add null-environment and scheme-report-environment

This commit is contained in:
Yuichi Nishiwaki 2014-07-27 14:29:08 +09:00
parent fd8330cca3
commit 076698c84a
3 changed files with 34 additions and 1 deletions

View File

@ -8,6 +8,8 @@ list(APPEND PICLIB_SCHEME_LIBS
${PROJECT_SOURCE_DIR}/piclib/scheme/file.scm
${PROJECT_SOURCE_DIR}/piclib/scheme/case-lambda.scm
${PROJECT_SOURCE_DIR}/piclib/scheme/lazy.scm
${PROJECT_SOURCE_DIR}/piclib/scheme/r5rs.scm
${PROJECT_SOURCE_DIR}/piclib/scheme/null.scm
${PROJECT_SOURCE_DIR}/piclib/srfi/1.scm
${PROJECT_SOURCE_DIR}/piclib/srfi/8.scm
${PROJECT_SOURCE_DIR}/piclib/srfi/26.scm

View File

@ -1073,3 +1073,20 @@
(apply values args)))))))))))))
(export guard)
(define-library (scheme eval)
(import (scheme base))
(define (null-environment n)
(if (not (= n 5))
(error "unsupported environment version" n)
'(scheme null)))
(define (scheme-report-environment n)
(if (not (= n 5))
(error "unsupported environment version" n)
'(scheme r5rs)))
(export null-environment
scheme-report-environment
))

View File

@ -7,5 +7,19 @@
(define (call-with-output-file filename callback)
(call-with-port (open-output-file filename) callback))
(define (with-input-from-file filename thunk)
(call-with-input-file filename
(lambda (port)
(parameterize ((current-input-port port))
(thunk)))))
(define (with-output-to-file filename thunk)
(call-with-output-file filename
(lambda (port)
(parameterize ((current-output-port port))
(thunk)))))
(export call-with-input-file
call-with-output-file))
call-with-output-file
with-input-from-file
with-output-to-file))