On Sat, 25 Oct 2008, John Cowan wrote:

> 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.

I have concerns about what you're saying here as it affects Scheme, but 
before I say anything, I would like to clarify something:  What would be 
the Q S-expression equivalent to (+ 1 (+ 2 (+ 3 4)))?  That is, the Scheme 
expression one would have to use instead of your example if Scheme + was 
strictly binary?

>> 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."

Yes, I am aware that in many proofs 0 is special, irrelevant, or 
inapplicable.  In particular, anytime one is discussing issues related to 
prime factorization, only the non-zero values are of interest.  And of 
course, lots of number theory uses prime factorization.  But when numbers 
are used for their most basic purpose -- counting -- they must start with 
0.

Isaac Morland                   CSCF Web Guru
DC 2554C, x36650                WWW Software Specialist

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

Reply via email to