add make-parameter and parameterize

This commit is contained in:
Yuichi Nishiwaki 2014-01-09 00:39:45 +09:00
parent a9f4eff13e
commit d0713456ef
1 changed files with 33 additions and 1 deletions

View File

@ -327,9 +327,38 @@
let*-values
define-values))
;;; parameter
(define-library (picrin parameter)
(import (scheme base)
(picrin macro)
(picrin core-syntax)
(picrin bootstrap-tools))
;; reopen (pircin parameter)
;; see src/var.c
(define-syntax parameterize
(er-macro-transformer
(lambda (form r compare)
(let ((bindings (cadr form))
(body (cddr form)))
(let ((vars (map car bindings)))
`(,(r 'let) (,@(map (lambda (var)
`(,(r var) (,var)))
vars))
,@bindings
(,(r 'let) ((,(r 'result) (begin ,@body)))
,@(map (lambda (var)
`(,(r 'parameter-set!) ,var ,(r var)))
vars)
,(r 'result))))))))
(export parameterize))
(import (picrin macro)
(picrin core-syntax)
(picrin multiple-value))
(picrin multiple-value)
(picrin parameter))
(export let let* letrec letrec*
quasiquote unquote unquote-splicing
@ -344,6 +373,9 @@
let*-values
define-values)
(export make-parameter
parameterize)
(define (any pred list)
(if (null? list)
#f