add make-parameter and parameterize
This commit is contained in:
parent
a9f4eff13e
commit
d0713456ef
|
@ -327,9 +327,38 @@
|
||||||
let*-values
|
let*-values
|
||||||
define-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)
|
(import (picrin macro)
|
||||||
(picrin core-syntax)
|
(picrin core-syntax)
|
||||||
(picrin multiple-value))
|
(picrin multiple-value)
|
||||||
|
(picrin parameter))
|
||||||
|
|
||||||
(export let let* letrec letrec*
|
(export let let* letrec letrec*
|
||||||
quasiquote unquote unquote-splicing
|
quasiquote unquote unquote-splicing
|
||||||
|
@ -344,6 +373,9 @@
|
||||||
let*-values
|
let*-values
|
||||||
define-values)
|
define-values)
|
||||||
|
|
||||||
|
(export make-parameter
|
||||||
|
parameterize)
|
||||||
|
|
||||||
(define (any pred list)
|
(define (any pred list)
|
||||||
(if (null? list)
|
(if (null? list)
|
||||||
#f
|
#f
|
||||||
|
|
Loading…
Reference in New Issue