[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [NOISE] Curly braces [was Re: Curl]



   Date: Thu, 29 Nov 2001 22:11:44 -0800 (PST)
   From: Morgan McGuire <morgan3d@yahoo.com>

   Infix math is a special language well suited to dense algebraic
   expressions, just like Scheme is a special language well suited to
   writing compilers.  Scheme is good for walking around on parse trees
   (of itself!), infix is good for math.  

A compensation for having graying hair is that I get to toss in
old-fogey comments like this: an infix syntax for math that could be
used anywhere in Lisp already existed over 25 years ago, at the MIT AI
lab.  It was called CGOL and was implemented by Vaughan Pratt as a
MacLisp "reader-macro".

I don't know if it got much use.  I and the friends with whom I worked
most closely at the time certainly have earnestly argued that

 (> (/ (+ (- b) (sqrt (- (* b b) (* 4 a c)))) (* 2 a) 0)

was the truest, rightest, and best of all possible syntacies.  It
might have been used outside of my circle, although at the time I'm
not sure there were a lot of people actually doing much math in
MacLisp.  Guy Steele might know more than I.

As I said before, terse syntax tends to be better when it's in an area
that you use frequently.  Since I didn't do much math stuff, I would
have found it hard to remember all the precedence rules that you have
to have wired into your head in order to effortlessly parse infix math
syntax mentally as you read the code.  How many of you actually know
by heart the complete ranking of operator precedence in, say, C or C++
or Java or any of these lanaguges that use infix math syntax?  The
last time I looked, one usually ends up with something like twenty
levels of precedence.  I put in parens rather than try to memorize all
that or, perhaps more to the point, assume that the reader of my code
have memorized it.