Re: [Scheme-reports] Formal definitions [con'd]
Jean-Michel HUFFLEN 03 Dec 2012 21:29 UTC
Alex Shinn <alexshinn@gmail.com> wrote:
> On Fri, Nov 30, 2012 at 8:29 AM, Jean-Michel HUFFLEN
> <jmhuffle@femto-st.fr>wrote:
> (...)
>> - p. 71, "make-parameter": your definition accepts any positive number
>> of arguments with :
>>
>> (define (make-parameter init . o) ...)
>>
>> Why not using "case-lambda", for "make-parameter" as well as its
>> result?
>
> Because this is actually longer than the cond version.
OK. But I would remark that in your version, you do not check that
there is no additional information which would be useless. If we do
that, that is:
(define (make-parameter init . o)
(let* ((converter (cond ((null? o) values)
((pair? (cdr o)) (error "bad parameter syntax"))
(else (car o))))
(values (converter init)))
(lambda args
(cond ((null? args) value)
((and (eq? (car args) <param-set!>) (pair? (cdr args))
(null? (cddr args)))
(set! value (cadr args)))
((and (eq? (car args) <parameter-convert>) (null? (cdr args)))
converter)
(else (error "bad parameter syntax"))))))
the result is still shorter than the version using "case-lambda", but
just slightly shorter.
Yours sincerely,
J.-M.
----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.
_______________________________________________
Scheme-reports mailing list
Scheme-reports@scheme-reports.org
http://lists.scheme-reports.org/cgi-bin/mailman/listinfo/scheme-reports