Python syntax in Lisp and Scheme

Pascal Bourguignon spam at thalassa.informatimago.com
Tue Oct 7 19:06:22 EDT 2003


Marcin 'Qrczak' Kowalczyk <qrczak at knm.org.pl> writes:

> On Tue, 07 Oct 2003 21:59:11 +0200, Pascal Bourguignon wrote:
> 
> > When you have macros such as loop that allow you to write stuff like:
> > 
> > (loop for  color in '(blue white red)
> [...]
> 
> Well, some people say the "loop" syntax is not very lispish - it's unusual
> that it uses many words and few parentheses. It still uses only words and
> parentheses, no other punctuation, and it introduces one pair of parentheses
> for its one nesting level.

Yes.   The point is  that the  language is  rather agnostic  about any
topic, even about the syntax.   Personnaly I don't like much LOOP, but
I take it as an example by the language designers showing us that it's
even possioble to avoid parethensis if you don't want them.

 
> A richer alphabet is often more readable. Morse code can't be read as fast
> as Latin alphabet because it uses too few different symbols. Japanese say
> they won't abandon Kanji because it's more readable as soon as you know it -
> you don't have to compose words from many small pieces which look alike
> but each word is distinct. Of course *too* large alphabet requires long
> learning and has technical difficulties, but Lisp expressions are too
> little distinctive for my taste.

Well,  I would say  that kanji  is badly  designed, compared  to latin
alphabet.   The voyels  are composed  with consones  (with diacritical
marks) and  consones are  written following four  or five  groups with
additional diacritical  marks to  distinguish within the  groups. It's
more a phonetic code than a true alphabet.

 
> I know I can implement infix operators with Lisp macros, but I even don't
> know how they feel because nobody uses them (do I have to explicitly open
> infix region and explicitly escape from it to regular syntax?), and
> arithmetic is not enough. 

Most  probably, you  would write  a  macro named  WITH-INFIX and  thus
automatically scope the infix part:

    (with-infix  1 / x + 1 / ( x ^ 3 ) +  1 / ( x ^ 5 ) )

and if you write it well:
    
    (with-infix
      if a = b then format t "equal ~D~%" a ;  
        else format t "diff ~D /= ~D~%" a b ; endif ;
      for i = 1 to 10 ; print i ; next i )


> All Lisp code I've read uses lots of parentheses
> and they pile up at the end of each large subexpression so it's hard to
> match them (an editor is not enough, it won't follow my eyes and won't
> work with printed code).
> 
> Syntax is the thing I like the least in Lisp & Scheme.

I'll tell you the secret: yes  there are alot of parethesis. This is a
price  all  lispers  pay  for  greater benefits.   It  gives  us  such
advantages that we gladly pay the price.

Otherwise, I would say:

    1- don't pay so much attention to the parenthesis!

    2- if you have to and it's hard, then it means the code is badly
       structured (probably too big a function). Rewrite it, factorize.

    3- what do you mean  "printed"?  A double-click on any parenthesis
       selects the enclosed list so it's quite easy to  see what it encloses.



-- 
__Pascal_Bourguignon__
http://www.informatimago.com/
Do not adjust your mind, there is a fault in reality.




More information about the Python-list mailing list