Alaric Snell-Pym <[EMAIL PROTECTED]> 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))


_______________________________________________
Chicken-users mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/chicken-users

Reply via email to