[r6rs-discuss] [Formal] SRFI-39 should be made an R6RS library

From: Abdulaziz Ghuloum <aghuloum>
Date: Wed Feb 21 00:45:16 2007

On Feb 20, 2007, at 11:05 PM, John Cowan wrote:

> It requires considerable behind-the-scenes machinery, as you can see,

I don't think this demonstrates any implementation complexity of
parameters.
If you intended this to demonstrate something else besides how
complex it is
implemented in chicken, then please explain.

For what it's worth, the implementation of make-parameter and
parameterize in
my compiler (ikarus) is almost identical to what Kent posted two
messages up.
The following is taken directly from the source of the implementation:

(define make-parameter
   (case-lambda
     [(x)
      (case-lambda
        [() x]
        [(v) (set! x v)])]
     [(x guard)
      (unless (procedure? guard)
        (error 'make-parameter "~s is not a procedure" guard))
      (set! x (guard x))
      (case-lambda
        [() x]
        [(v) (set! x (guard v))])]))

(define-syntax parameterize
   (lambda (x)
     (syntax-case x ()
       [(_ () b b* ...) #'(let () b b* ...)]
       [(_ ([olhs* orhs*] ...) b b* ...)
        (with-syntax ([(lhs* ...) (generate-temporaries #'(olhs* ...))]
                      [(rhs* ...) (generate-temporaries #'(orhs* ...))])
         #'(let ([lhs* olhs*] ...
                 [rhs* orhs*] ...)
             (let ([swap
                    (lambda ()
                      (let ([t (lhs*)])
                        (lhs* rhs*)
                        (set! rhs* t)) ...)])
               (dynamic-wind
                 swap
                 (lambda () b b* ...)
                 swap))))])))

With the exception of a call to error, everything in this code is
portable
as far as R5.92RS is concerned.

Aziz,,,

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.r6rs.org/pipermail/r6rs-discuss/attachments/20070221/60824c6b/attachment.htm
Received on Wed Feb 21 2007 - 00:44:32 UTC

This archive was generated by hypermail 2.3.0 : Wed Oct 23 2024 - 09:15:01 UTC