3 ms·
And even in the LISPs that did give up dynamic binding, you can still emulate it to some degree. E.g. in Scheme: (define-syntax fluid-let (syntax-rules (
by nils-m-holm 8y ago
And even in the LISPs that did give up dynamic binding, you can still emulate it to some degree. E.g. in Scheme:
(define-syntax fluid-let
(syntax-rules ()
((_ () x . xs)
(begin x . xs))
((_ ((v1 a1) (v2 a2) ...) x . xs)
(let ((tmp v1))
(set! v1 a1)
(fluid-let ((v2 a2) ...)
(let ((r (begin x . xs)))
(set! v1 tmp)
r))))))
(define x 'foo)
(define (f) x)
(f) ==> foo
(fluid-let ((x 'bar))
(f)) ==> bar