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

Lispy vs Pseudo-English Syntax



I think the biggest problem we're going to have in coming up with a
standard iteration syntax is in finding some syntax that most of us can
live with.  Many of us deeply dislike the cutesy psuedo-English style of
the Zetalisp/Maclisp LOOP macro, yet the proponents of this style seem
to regard it as sacred.  I don't have my Chine Nual handy, but I recall
a sentence in there that says, more or less, the following: "Some may
feel that this English-like style is verbose and unsightly.  These
people are invited to use DO instead."  Well, I'm one of those people,
and I've been using DO instead.  I don't even like to read that other
stuff, let alone try to write it.  Still, I can see the desirability of
having facilities like COLLECT and MAXIMIZE built into Common Lisp, so
that people don't have do such things in ad hoc ways inside of DO loops.

The kind of syntax in the PSL FOR macro (as described in the recent note
by Shebs) looks much better to me: a free mixture of clauses, each
introduced by a keyword and each one in a sublist of its own.  I think
that this question of syntax is orthogonal to the other differences
between FOR and LOOP; whatever we decide to do about such issues as
order-of-evaluation constraints, user extensibility, which forms to
include, and so on, it should be possible to implement these decisions
in either syntax.

The lispy syntax of FOR seems better to me for a number of reasons:

1. I don't like pseudo-English in those business-oriented langauges that
try to dupe businessmen into believing that they can program their
IBM-PC in raw English, and I like pseudo-English even less in Lisp
(whose power would make such claims more plausible but no more true).
We are dealing here with a very restricted, very precise formal language
with a simple, dumb parser.  It is a cruel hoax to pretend that this is
English and that the resulting code means just what the corresponding
English sentence would mean.  You must carefully understand and memorize
what each of the keywords means in each context -- you cannot just write
a sentence and expect the Lisp system to do the right thing.  I find
such pseudo-English to be more confusing than an obviously artificial
language, not less.

2. I believe that the parenthesized form is easier to read quickly, at
least for people used to Lisp syntax.  The grouping of operators and
their arguments is visually evident; it is much harder for me to
immediately grasp what some run-on pseudo-sentence, with chunks of
undigested Lisp code floating around in it, is going to do.

3. The unusual syntax of LOOP makes life difficult for various
components of the programming environment.  The difficulty of parsing
the pseudo-English in the LOOP macro itself is not really an issue,
since that code only needs to be written once and prototypes already
exist, but a lot of other tools such as pretty printers would have to be
modified to understand which keywords want to cause line breaks, etc.

4. Where a clause takes more than one argument-like form, the lispy
syntax is more flexible.  An explictly delimited clause can take any
number of by-position arguments, while the LOOP syntax requires that
each of the additional arguments either be recognizable as a non-keyword
or that it be introduced by some marker, usually an English preposition
like "by" or "to".  I find it very difficult to remember which of these
little syntactic markers go with which clauses and perform which
operations.

5. The conceit that a LOOP expression should read like a grammatical
English sentence (though one that is unlikely to come up in polite
converstion) leads to some poor choices of keywords.  In order to get
the pseudo-sentences to sound right when pronounced, you need to define
lots of synonyms, so that both the singular and plural forms, or both
plain and "ing" forms, are allowed.  Keywords are chosen so that the
sentences sound natural, rather than on the basis of how clearly they
will convey the precise meaning of the operation.

As far as number of keystrokes are concerned, I think it's about even.
The parentheses add up, but often a couple of parentheses can eliminate
two or three little connecting words.  It seems to me that the principal
advantages of the LOOP syntax are that some people are used to it
already and that some small number of people think that it is cute.

Comments?

Two additional thoughts:

The labelled clauses in the FOR syntax look too much like Lisp
expressions, since some of the labels are identical to built-in Lisp
functions and special forms.  I can imagine some Emacs character macro
being screwed by trying to find all the (unless ...) expressions and not
realizing that the ones inside a FOR construct are different from the
ones outside.  Maybe these labels should be keywords, as in (:unless
expression) ?  One more character to type, but it would make it very
easy to distinguish the clauses of an iteration from random functions
and special forms.

I suppose that one possibility would be sanction both the Lisp-like and
pseudo-English types of syntax, with a simple one-to-one correspondence.
Then people could write in whichever surface style they choose, and they
could even convert programs written by others into their own preferred
syntax before trying to understand them.  I don't much like this kind of
solution, but if there is an irreconcilable division over this issue of
syntax, this might be better than no solution at all.

-- Scott