guile-user
[Top][All Lists]
Advanced

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

Re: 1+ is not R5RS


From: Keith Wright
Subject: Re: 1+ is not R5RS
Date: Thu, 18 Dec 2008 23:24:25 -0500

> From: Clinton Ebadi <address@hidden>
> Cc: address@hidden
> 
> address@hidden (Ludovic Courtès) writes:
> > "Bertalan Fodor (LilyPondTool)" <address@hidden> writes:
> >> Could you provide me some background why 1+ exists, as it is the same
> >> as (+ 1, and why is it named like this?
> >
> > It'll be hard to get a definite answer: these procedures have "always"
> > been there, at least since [1996]
> > That's a long time ago...
> 
> Probably because Common Lisp has 1+ and 1-.

I think it was longer ago than that.  Maybe closer to
1969 than 1996.  Some LISP 1.5 programmer got tired of
typing (add1 x) and (sub1 x) to get the successor and
predecessor of x, and noticed that (1+ x), except for
spacing, looks just like infix notation.  Cool.

Remember, at that time the straightforward way to write
it out in full was not (+ 1 x), but (plus x 1).  Use of
function names that are not alphanumeric is a "modern"
innovation.

Unfortunately, predecessor doesn't work out so well.
You can change "+" to "-", and get (1- x) for
predecessor, but read as infix notation that is exactly
backward.  It would work to write (-1+ x), but now it
is as troublesome to type as (sub1 x).  We never liked
infix all that much, so we go with "consistency".

If I had it to do over, I would pick
  (define (++ x) (+ x 1))
  (define (-- x) (- x 1))
but all this happened before C was a gleam in K&R's
eyes, and so that was not obvious back then.

   -- Keith




reply via email to

[Prev in Thread] Current Thread [Next in Thread]