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,,,
_______________________________________________
r6rs-discuss mailing list
[email protected]
http://lists.r6rs.org/cgi-bin/mailman/listinfo/r6rs-discuss

Reply via email to