Newsgroups: comp.lang.lisp
Path: cantaloupe.srv.cs.cmu.edu!bb3.andrew.cmu.edu!nntp.sei.cmu.edu!news.psc.edu!hudson.lm.com!news.math.psu.edu!news.cac.psu.edu!newsserver.jvnc.net!newsserver2.jvnc.net!howland.reston.ans.net!gatech!news.mathworks.com!tank.news.pipex.net!pipex!dispatch.news.demon.net!demon!uknet!newsfeed.ed.ac.uk!festival!jeff
From: jeff@festival.ed.ac.uk (J W Dalton)
Subject: Re: LisP aesthetics (was Re: Testing for EOF)
References: <3u1f98$l9n@usenet.srv.cis.pitt.edu> 	<ANDERSON.95Jul14175810@earhart.cs.umass.edu> 	<CGAY.95Jul15101459@ix.cs.uoregon.edu> <DC576r.Byw@rheged.dircon.co.uk> <ANDERSON.95Jul25175039@earhart.cs.umass.edu>
Message-ID: <DD5nFy.5ps@festival.ed.ac.uk>
Organization: Edinburgh University
Date: Fri, 11 Aug 1995 16:35:58 GMT
Lines: 73

anderson@earhart.cs.umass.edu (Scott D. Anderson) writes:

>In simon@rheged.dircon.co.uk (Simon Brooke) writes:

>> gxcst+@pitt.edu (Gil Citro), a new LisPer, posted a question about
>> slurping a text file into a list of strings, and Barry Margolin and
>> Scott Anderson responded with very similar sample solutions. Both made
>> use of the new LOOP macro. Here is Scott's solution:
>> 
>> >   From: anderson@cs.umass.edu (Scott D. Anderson)
>> >   Date: 14 Jul 1995 21:58:10 GMT
>> 
>> >   (defun char-count (file)
>> >     (with-open-file (in file)
>> >       (loop for x = (read-line in nil nil)
>> >	     while x
>> >	     sum (length x) into count
>> >	     finally (return count))))
>> 
>> I read it, and didn't believe it, and then read it again and didn't
>> understand it, and finally read it and profoundly disliked it. We all
>> have our own ideas about what the soul of LisP is, and one of the good
>> things about LisP is undoubtedly the facility with which macros can be
>> used to implement new mini-languages.

>Even though Simon has singled me out for an especially visible place in
>his hall of shame, I am going to -- *partially* -- agree with him.  I'm
>not going to agree that my code is unreadable or ugly.  When someone asked
>me about Simon's article, I was able to recite my code from memory, which
>I don't think could be done if it weren't fairly clear and simple.  But
>I'll leave that to others to judge.

Well, why does it have the count variable?  The following seems
to work:

  (defun char-count (file)
    (with-open-file (in file :direction :input)
      (loop for line = (read-line in nil nil)
            while line
            sum (length line))))

Such simple uses of loop could be rewritten in a more Lispy way
without much trouble.  A reduce applied a lazy list of file lines,
for example.  There are also some fairly simple and efficient
collection macros that one might use.

>What's the point of all those parentheses, if we can do without them
>in languages like LOOP?

>I believe that the point of Lisp syntax is to write code in a form that is
>easily written by or analyzed by a program, particularly a Lisp program.

That may be *a* point.

But I prefer Lisp syntax even apart from macros, and I've happily
used Lisps that didn't have macros.  I do not in any way put up
with the Lisp syntax in order to get some compensating benefits.

I don't mind if you see things differently, but you shouldn't
say "_the_ point of Lisp syntax" [emphasis added].

>I disagree with Simon about simplicity, clarity, and even aesthetics. I
>think Simon's new subject for this thread, "aesthetics," isn't right.  I
>don't mind Lisp's parentheses--I kinda like them--but they're there for
>function, not beauty. 

That's an opinion, sure.

BTW, the source syntax of Lisp could be fairly different without
changing how macros worked at all.  Most Lisp programmers have
preferred Lisp syntax to such alternatives.

-- jd
