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

Abdulaziz Ghuloum aghuloum at cs.indiana.edu
Wed Feb 21 00:44:32 EST 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


More information about the r6rs-discuss mailing list