Re: A style question



On Feb 27, 9:02 pm, job-271842...@xxxxxxxxxxxxxx wrote:
[...]
Thanks. Some questions/comments:

1) In "ANSI Common Lisp", Graham makes the following comments:

"The loop macro was originally designed to help inexperienced
Lisp users write iterative code...Unfortunately, loop is more like
English than its designers ever intended...to understand it in the
abstract is almost impossible...For such reasons, the use of loop
cannot be recommended."

Is this a minority view?

I think it is. I cordially despise LOOP myself, but almost everyone
uses it for simple stuff some of the time. You can avoid it entirely
if you want, but it can make your life unneccessarily difficult do.

You should spend some time becoming familiar with it. At the very
least, you need a basic understanding to read other people's
code. Then you can make an informed decision to avoid it. :)

One of the things that attracted me to Lisp was the simplicity,
consistency, etc. of the language, so when I read the above, it
seemed reasonable.

Common Lisp is in some ways simple, and pretty consistent, but it's
also huge and not particularly "pure". Personally, I like the sense of
compromise and age.

Others prefer Scheme, which is a different dialect of Lisp which is
all about being small and elegant and pure. I find it sterile and
spare and unfun myself.

3) Any reason why you chose (when fizz (princ "Fizz")) instead of (if
fizz (princ "Fizz")) ?

It's a little bit of Common Lisp style. If you are only going to use
the true branch of the conditional, use "when", and if you're only
going to use the false branch, use "unless".

Hope you continue to have fun.

Cheers,
Pillsy

.



Relevant Pages

  • How to Speed up Cellular Automata [was Re: How to speed up an OpenGL application?]
    ... In the loop you hit aref a dozen times, god knows what else, without an iota of optimization. ... Lisp does more by default, so if you need to write ... (if (zerop cell) ...
    (comp.lang.lisp)
  • Re: A style question
    ... "The loop macro was originally designed to help inexperienced Lisp ... than its designers ever intended...to understand it in the abstract is ... I started playing with it, but I am just an elder, not a Lisp elder. ...
    (comp.lang.lisp)
  • Re: Very poor Lisp performance
    ... Observe LOOP, ... than many Lisp users, as LOOP is offensive to a percentage of Lisp ... >>> natural and programming languages have complicated grammars precisely ... do you agree that languages are evolving to be more concise? ...
    (comp.lang.lisp)
  • Re: YANQ - When to map, when to iterate, when to recurse? And why CLOS?
    ... Is it just LOOP allergy, ... > lot of iteration constructs in other languagesis it just a matter of taste, ... controversial Common Lisp form, in that there are a fair number of Lisp ... There's also a more obscure solution involving the PROG1 form, ...
    (comp.lang.lisp)
  • efficiently accumulating values
    ... do (loop as j from 0 to (1- n) ... do (let ((old (aref matrix i j))) ... acc (rec ni nj word acc) ... Is there an efficient way to accumulate values in lisp? ...
    (comp.lang.lisp)