chicken-users
[Top][All Lists]
Advanced

[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: Tue, 17 Jul 2007 00:33:41 +0700

Alaric Snell-Pym <address@hidden> writes:

>> It's up to the caller to supply a correct alist to the function.
>> E. g.:

> Ah, but the original problem was that the alist was read from a file,
> at run time!

       Well, symbols may either be simply `eval'ed, or ``mapped'' to
       their respective parameters.  Since the symbols are going from
       file, I'd recommend you to ``map'' them.

       Given that the ``parameter object'' is indistinguishable from a
       procedure of one optional argument, the ``mapping'' function
       could be used to signal an error if an invalid symbol was
       specified in the file.  E. g.:

(define *the-mapping*
 `((stdout . ,current-output-port)
   (stdin  . ,current-input-port)
   ))

(define (the-symbol->parameter sym)
 (cond ((assoc sym *the-mapping*) => cdr)
       (else (error "invalid parameter:" sym))))

(define (the-alist->parameters alist)
 (map (lambda (pair)
        (cons (the-symbol->parameter (car pair))
              (cdr pair)))
      alist))




reply via email to

[Prev in Thread] Current Thread [Next in Thread]