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

Abdulaziz Ghuloum aghuloum at cs.indiana.edu
Wed Feb 21 03:10:11 EST 2007


On Feb 21, 2007, at 2:20 AM, Michael Sperber wrote:

> The problem is that seemingly simple code can have complex behavior.
> In this case, the complexity derives from `swap'.

This is the implementation of fluid-let as in TSPL3:

   (define-syntax fluid-let
     (syntax-rules ()
       ((_ ((x v)) e1 e2 ...)
        (let ((y v))
          (let ((swap (lambda () (let ((t x)) (set! x y) (set! y t)))))
            (dynamic-wind swap (lambda () e1 e2 ...) swap))))))

And here is the implementation of parameterize (simplified to one  
binding):

   (define-syntax parameterize
     (syntax-rules ()
       [(_ ((x v)) e1 e2 ...)
        (let ([p x] [y v])
          (let ([swap (lambda () (let ([t (p)]) (p y) (set! y t)))])
            (dynamic-wind swap (lambda () e1 e2 ...) swap)))]))

All the code does is "swap before going in" and "swap when you come  
out".
I honestly fail to see the complexity.

Aziz,,,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.r6rs.org/pipermail/r6rs-discuss/attachments/20070221/f8ea49f0/attachment.html


More information about the r6rs-discuss mailing list