[Openmcl-devel] Trunk and released version
Tobias C. Rittweiler
tcr at freebits.de
Thu Aug 13 19:05:34 UTC 2009
Ron Garret <ron at flownet.com> writes:
> Huh? How would removing the requirement of having VAR rebound (or
> reassigned) to NIL make it harder to implement DOLIST in terms of DO*?
> For that matter, what would be wrong with:
> (defmacro sane-dolist ((var list &optional ret) &body body)
> `(do* ((l1 ,list (cdr l1)) (,var (car l1) (car l1)))
> ((null (cdr l1)) (progn , at body) ,ret)
> , at body))
Let's ignore the obvious name capture of L1, I think that was on purpose
not to cludder the example too much.
First, the (PROGN , at BODY) won't allow declarations, so you do your first
revision and write (LET () , at BODY). But then you discover that this
won't allow implicit tags, and so you do your next revision and write
(PROG () , at body).
And then you discover that it doesn't change the original issue
(declaring VAR to be fixnum) for the empty list case. So you do your
third revision and wrap everything around an (UNLESS (ENDP ,LIST)), but
now you have additionally to take care of double evaluation, fourth
Not to mention that duplicating a large BODY is probably not a good idea
for it filling up the cache line unnecessarily.
With DOLIST being specified as it is, you can expand it to
(do* ((#1=#:l <list> (cdr #1#))
(<var> (car #1#) (car #1#)))
((null #1#) <return>)
(declare (list #1#))
and be done with it.
More information about the Openmcl-devel