On Tue, Sep 13, 2011 at 12:04 PM, Panicz Maciej Godek
<godek.mac...@gmail.com> wrote:
> 2011/9/13, Andrew Gwozdziewycz <apg...@gmail.com>:
>>
>> 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

Ah, yes. I believe there's no way around using eval here. The
difficulty of course is compile time vs. runtime.


-- 
http://www.apgwoz.com

Reply via email to