Message from discussion I would appreciate a code review
From: Jock Cooper <jo...@mail.com>
Subject: Re: I would appreciate a code review
Date: 07 Nov 2003 10:48:12 -0800
References: <firstname.lastname@example.org> <email@example.com>
Content-Type: text/plain; charset=us-ascii
User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2
Kent M Pitman <pit...@nhplace.com> writes:
> Style note: Avoid DO* if you can. It's tricky to move back and forth between
> DO and DO*, and, frankly, I've never found a need for DO*.
I don't use DO* when DO will do, but I have found uses for DO*. However I
just did a survey of my code and most of my use of DO* is something like
(DO* ((somecdr somelist (cdr somecdr))
(someitem (car somecdr) (car somecdr))
which I suppose is poor style. But how about something like this?:
(do* ((top (1- (length the-array)))
(middle #1=(truncate (/ (+ top bottom) 2)) #1#)
(row #2=(funcall key-fun (aref the-array middle)) #2#)
(eq-p #3=(funcall eq-fun look-for row) #3#)
((or eq-p (> bottom top))
(if eq-p (values middle nil) (values nil top)))
(if (funcall less-fun look-for row)
(setq top (1- middle))
(setq bottom (1+ middle))))))
Of course this could be coded any number of ways, but is there a
good reason why I *shouldn't* use DO* here?
> The useful one of the two is DO because DO can be directly transliterated
> to tail call procedures like Scheme programmers write. DO* has no such
> useful property.
Can you elaborate on this last part?