unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: Keith Wright <kwright@keithdiane.us>
To: guile-user@gnu.org
Cc: clinton@unknownlamer.org, ludo@gnu.org
Subject: Re: 1+ is not R5RS
Date: Thu, 18 Dec 2008 23:24:25 -0500	[thread overview]
Message-ID: <200812190424.mBJ4OPEG003963@fcs13.keithdiane.us> (raw)
In-Reply-To: <878wqd3ykl.fsf@unknownlamer.org> (message from Clinton Ebadi on Thu, 18 Dec 2008 17:31:22 -0500)

> From: Clinton Ebadi <clinton@unknownlamer.org>
> Cc: guile-user@gnu.org
> 
> ludo@gnu.org (Ludovic Courtès) writes:
> > "Bertalan Fodor (LilyPondTool)" <lilypondtool@organum.hu> 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	other threads:[~2008-12-19  4:24 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-18 15:17 1+ is not R5RS Bertalan Fodor (LilyPondTool)
2008-12-18 21:09 ` Ludovic Courtès
2008-12-18 22:31   ` Clinton Ebadi
2008-12-19  4:24     ` Keith Wright [this message]
2008-12-19  9:43   ` Ralf Mattes
2008-12-19  6:09 ` Linas Vepstas
2008-12-19  7:41   ` Bertalan Fodor
2008-12-19 16:34     ` Linas Vepstas
  -- strict thread matches above, loose matches on Subject: below --
2008-12-19 19:29 Bertalan Fodor

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200812190424.mBJ4OPEG003963@fcs13.keithdiane.us \
    --to=kwright@keithdiane.us \
    --cc=clinton@unknownlamer.org \
    --cc=guile-user@gnu.org \
    --cc=ludo@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).