[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: progv in scheme
From: |
Panicz Maciej Godek |
Subject: |
Re: progv in scheme |
Date: |
Tue, 13 Sep 2011 18:04:05 +0200 |
2011/9/13, Andrew Gwozdziewycz <address@hidden>:
>
> Seems likely that you could use `syntax-case' to create a `let` out of
> these:
>
> (define-syntax progv
> (lambda (stx)
> (define (create-bindings syms vals)
> (datum->syntax stx (zip (syntax->datum syms) (syntax->datum vals))))
> (syntax-case stx ()
> ((_ symbols values body ...)
> (with-syntax ((bindings (create-bindings #'symbols #'values)))
> #'(let bindings
> (begin body ...)))))))
>
>
>
> ;; usage
> (progv (foo bar baz) (1 2 3)
> (format (current-output-port) "Values: ~a ~a ~a\n" foo bar baz))
> ;; output: "Values: 1 2 3"
Hey,
thanks for this code, maybe one day I will be able to comprehend it :)
for now, the problem is that I want to bind the variables that are
contained within a list, and that I don't know what's in that list.
So, the following code should work as well:
(let ((s '(foo bar baz))
(v '(1 2 3)))
(progv s v
(+ foo bar baz)))
===> 6
regards
M.