Message from discussion
I would appreciate a code review
Path: archiver1.google.com!news2.google.com!fu-berlin.de!pln-w!spln!dex!extra.newsguy.com!newsp.newsguy.com!enews2
From: Jock Cooper <jo...@mail.com>
Newsgroups: comp.lang.lisp
Subject: Re: I would appreciate a code review
Date: 07 Nov 2003 10:48:12 -0800
Organization: http://extra.newsguy.com
Lines: 34
Sender: jo...@jcooper02.sagepub.com
Message-ID: <m3y8usxbf7.fsf@jcooper02.sagepub.com>
References: <90ac4ec2.0311061901.658716ba@posting.google.com> <wku15gfz7g.fsf@nhplace.com>
NNTP-Posting-Host: p-071.newsdawg.com
Mime-Version: 1.0
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))
... etc...))
which I suppose is poor style. But how about something like this?:
(do* ((top (1- (length the-array)))
(bottom 0)
(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?