Gareth McCaughan <Gareth.McCaug
...@pobox.com> writes:
> 2. I like to be able to get a lot of code into a small
> space; I can think about it much better that way.
> I know that you don't think #1 is worth bothering about;
> that's up to you. Let's look at #2.
> Compare the following two code fragments.
> (defun build-upward-closures ()
> (loop for k from *maxplay* downto 0 do
> (setf (aref *upward-closures* k)
> (let ((result (ash 1 k)))
> (loop for i from 0 below *n* do
> (let ((k1 (logior k (ash 1 i))))
> (when (> k1 k)
> (setf result (logior result (aref *upward-closures* k1))))))
> result))))
> and
> (defun build-upward-closures ()
> (loop for k from *maxplay* downto 0 do
> (setf (aref *upward-closures* k)
> (let ((result (ash 1 k)))
> (loop for i from 0 below *n* do
> (let ((k1 (logior k (ash 1 i))))
> (when (> k1 k)
> (setf result (logior result (aref *upward-closures* k1)))
> )
> )
> )
> result
> )
> )
> )
> )
I've seen most of the style arguments based on philosophy posted
on this thread, but there is one argument I have not yet seen.
The most convincing argument for me to run with the first style is
what the lisp itself says:
user(1): (pprint '(defun build-upward-closures ()
(loop for k from *maxplay* downto 0 do
(setf (aref *upward-closures* k)
(let ((result (ash 1 k)))
(loop for i from 0 below *n* do
(let ((k1 (logior k (ash 1 i))))
(when (> k1 k)
(setf result (logior result (aref *upward-closures* k1)))
)
)
)
result
)
)
)))
(defun build-upward-closures ()
(loop for k from *maxplay* downto 0 do
(setf (aref *upward-closures* k)
(let ((result (ash 1 k)))
(loop for i from 0 below *n* do
(let ((k1 (logior k (ash 1 i))))
(when (> k1 k)
(setf result
(logior result
(aref *upward-closures* k1))))))
result))))
user(2):
In general, any lisp code that can be manipulated as data is
easier to work with if it matches the result of its pretty-printed
output. Now it is true that the pretty printer can be customized,
and thus you're not going to get exactly the same output if you
change, say, indentation rules and other attributes. But for all of
its customizability, I know of no way to tell the pretty-printer to
dangle its closing parens. Was this an oversight, or by design?
For Anthony Cartmell, I don't know IDL, and I've already posted
the opinion of an ICAD developer, but it seems to me that whether
or not IDL rules should allow for dangling parens should be weighed
heavily on whether or not a defpart is source-only, or whether it
is possible by any means to get hooks into the source (by way of
a code-walker, macroexpansion, or other debugging activity). If
the former, then it doesn't matter. If the latter, then unless
there have been extensions to ICAD's pretty-printer over CL's
printer, the intermediate forms will look "wrong", because they
will have no dangling parens.
--
Duane Rettig Franz Inc. http://www.franz.com/ (www)
1995 University Ave Suite 275 Berkeley, CA 94704
Phone: (510) 548-3600; FAX: (510) 548-8253 du...@Franz.COM (internet)