From: Chris Hanson Date: Sat, 27 Feb 2016 21:29:17 +0000 (-0800) Subject: Implement make-parameter*. X-Git-Tag: mit-scheme-pucked-9.2.12~261^2~123 X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=4c6d09dab929af49b419a95471e01184759eed79;p=mit-scheme.git Implement make-parameter*. --- diff --git a/src/runtime/dynamic.scm b/src/runtime/dynamic.scm index bf646a681..35db0bd68 100644 --- a/src/runtime/dynamic.scm +++ b/src/runtime/dynamic.scm @@ -53,18 +53,22 @@ USA. (define-guarantee parameter "parameter") -(define (make-parameter init #!optional converter) - (let* ((converter - (if (default-object? converter) - (lambda (x) x) - converter)) - (metadata (cons converter (converter init))) +(define (make-parameter initial-value #!optional write-converter) + (let ((noop (lambda (x) x))) + (make-parameter* initial-value + noop + (if (default-object? write-converter) + noop + write-converter)))) + +(define (make-parameter* initial-value read-converter write-converter) + (let* ((metadata (cons write-converter (write-converter initial-value))) (parameter (lambda (#!optional new-value) (let ((p (or (assq metadata bindings) metadata))) (if (default-object? new-value) - (cdr p) - (set-cdr! p (converter new-value))))))) + (read-converter (cdr p)) + (set-cdr! p (write-converter new-value))))))) (set-parameter-metadata! parameter metadata) parameter)) diff --git a/src/runtime/runtime.pkg b/src/runtime/runtime.pkg index e50101e45..431bf3539 100644 --- a/src/runtime/runtime.pkg +++ b/src/runtime/runtime.pkg @@ -4581,6 +4581,7 @@ USA. (export () parameter? make-parameter + make-parameter* parameterize*) (initialization (initialize-package!)))