[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-users] parameterize-from-alist
From: |
Ivan Shmakov |
Subject: |
Re: [Chicken-users] parameterize-from-alist |
Date: |
Mon, 16 Jul 2007 09:37:38 +0700 |
Alaric Snell-Pym <address@hidden> writes:
AS> He suggested I ask on The List, so here it is. Is there a way to
AS> write parameterize-from-alist without eval hackery, or shall I just
AS> use the wings dynamic environment?
>> 'Course. However, I'd recommend for it to be implemented as a
>> function, not as a macro.
>> (define (parameterize-from-alist alist thunk)
>> (let loop ((alist alist))
>> (if (not (null? alist))
>> (parameterize ((caar alist) (cdar alist))
>> (loop (cdr alist)))
>> (thunk))))
> But (caar alist) will return a symbol, not a parameter object?
It's up to the caller to supply a correct alist to the function.
E. g.:
(parameterize-from-alist (list (cons current-output-port
my-output-port))
(lambda ()
(display "Hello, world!")
(newline)))
Note that current-output-port evaluates to a parameter object,
not a symbol.