Re: Suggested change to the sample implementation, & other comments
Marc Nieper-WiÃkirchen 23 Oct 2022 11:36 UTC
Am Fr., 21. Okt. 2022 um 20:27 Uhr schrieb Marc Nieper-Wißkirchen
<xxxxxx@gmail.com>:
[...]
> Am Fr., 21. Okt. 2022 um 20:09 Uhr schrieb Göran Weinholt <xxxxxx@weinholt.se>:
> >
> > Hello Marc,
> >
> > Thanks for another interesting SRFI. I noticed that the sample
> > implementation uses a construction that neither Chez nor Loko optimizes:
> >
> > (expand/optimize
> > '(define set-car+cdr!
> > (lambda (p x y)
> > (assert (pair? p))
> > (perform
> > (set-car! p x)
> > (set-cdr! p y)))))
> > =>
> > (begin
> > (set! set-car+cdr!
> > (lambda (p x y)
> > (let ([t (pair? p)])
> > (if t
> > (void)
> > (assertion-violation #f "failed assertion (pair? p)")))
> > (call-with-values
> > (lambda () (set-car! p x))
> > (lambda g2
> > (call-with-values
> > (lambda () (set-cdr! p y))
> > (lambda g3 (values)))))))
> > (void))
>
> Thank you very much for making this test. I would have thought that
> Chez uses the ideas of Ashley/Dybvig's paper "Implementation of
> Multiple Return Values in Scheme" to eliminate the `call-with-values`
> calls. (As mentioned in that paper, `call-with-values` it is not a
> particularly good primitive because of the unnecessary closure
> generation).
BTW, is there an easy way to let Chez print the results of its
intermediate or final nanopasses?
Thanks, Marc