Isaac Morland scripsit:

> To me it seems obvious that insisting that < take exactly two arguments
> is unSchemely, and I am astonished that this is controversial.  One of
> the things that I first found elegant about Scheme was the fact that
> procedures can take a variable number of arguments, including 0, and
> the additional fact that the standard functions make use of this fact
> to extend procedures that normally take a fixed number of arguments
> to variable-argument procedures in a natural way.  Common programming
> idioms like "a + b + c + d" and "x<y and y<z" can be expressed more
> clearly and succintly than otherwise.

And yet.  I once wrote an interface from Chicken Scheme to the Q language.
Q is an embeddable interpreter, and I wanted to allow Scheme programmers
to pass expressions to Q either in its native syntax or using an
S-expression representation.  There were two main issues in deciding on
how to map Q's data structures onto S-expressions.  The first of these
was that Q is based on NORMALIZE and REDUCE like 2-Lisp, rather than
EVAL and APPLY like Scheme, so there had to be distinct S-expressions
for lists and combinations (procedure calls).

I chose to represent a combination as (q:call fn arg ...), which could not
be a Q list because "q:call" is not a valid Q symbol name.  Note that this
is *not* a Scheme expression, but a Q expression in S-expression form;
q:call is just a symbol to Scheme, not the name of a Scheme procedure.
The format was a tad verbose, but usable most of the time, and using
S-expressions meant that it was easy to construct quasi-quoted Q
expressions with Scheme embedded in them.

But then comes the fact that Q handles multiple arguments by currying,
and that's inconsistent with having variable numbers of arguments.
So (q:call +) just returns Q's + by normalization, (q:call + 1) returns
a function that adds 1 to its argument, (q:call + 1 2) returns 3, and
(q:call + 1 2 3) is equivalent to (q:call 3 3), which is an error.

So to write the Q S-expression equivalent to Scheme's (+ 1 2 3 4) one
must write (q:call + 1 (q:call + 2 (q:call + 3 4))).  Ugh.  Q's native
infix notation "1+2+3+4" is far more appealing.

> Next somebody is going to argue that the natural numbers start with 1, 

Quoth Wikipedia: "In mathematics, a natural number (also called counting
number) can mean either an element of the set {1, 2, 3, ...} (the positive
integers) or an element of the set {0, 1, 2, 3, ...} (the non-negative
integers). The former is generally used in number theory, while the latter
is preferred in mathematical logic, set theory, and computer science."

-- 
He made the Legislature meet at one-horse       John Cowan
tank-towns out in the alfalfa belt, so that     [EMAIL PROTECTED]
hardly nobody could get there and most of       http://www.ccil.org/~cowan
the leaders would stay home and let him go      --H.L. Mencken's
to work and do things as he pleased.              Declaration of Independence

_______________________________________________
r6rs-discuss mailing list
[email protected]
http://lists.r6rs.org/cgi-bin/mailman/listinfo/r6rs-discuss

Reply via email to