[cl-faq] faq answer: Lisp, ()'s, and indentation

Pascal Bourguignon pjb at informatimago.com
Tue Nov 28 11:53:41 CST 2006


Larry Clapp writes:
> *** I have this cool idea for a new Lisp dialect / Lisp syntax that
> doesn't involve so many parentheses!  It uses indentation to show
> structure!
> 
> Since the advent of Python, this comes up on c.l.l. with some
> regularity.  We've had "sweet-expressions" and "indented Lisp" and
> probably others.
> 
> Realize a few things:

Perhaps we could add some motivation for a delimited syntax in lisp.

We could remove the parentheses, when we know the arity of the operand.

For example:         (CONS A B)  

could be written      CONS A B

knowing that CONS takes a fixed number of two arguments.


However, there are two problems with that:

- We have variable arity functions.  A lot of them, including optional
  parameters and key parameters.  And we like it.

- We want to be able to process (parse, walk, and modify) in macros
  unknown forms: the macro must still work if it doesn't know the
  number of arguments needed by a user defined operator.  Therefore
  even if we allowed only fixed arity, we would need a way to keep
  track of this fixed number of arguments. 

Given that we want both, using parentheses is one of the best solutions.

(If we wanted only the later, like in prolog, we could put the number
of arguments with the operator name:
   cons/2 a b
   if/2 c if/3 d x y
)



-- 
__Pascal Bourguignon__                     http://www.informatimago.com/
-----BEGIN GEEK CODE BLOCK-----
Version: 3.12
GCS d? s++:++ a+ C+++ UL++++ P--- L+++ E+++ W++ N+++ o-- K- w--- 
O- M++ V PS PE++ Y++ PGP t+ 5+ X++ R !tv b+++ DI++++ D++ 
G e+++ h+ r-- z? 
------END GEEK CODE BLOCK------


More information about the cl-faq mailing list