> From: Clinton Ebadi <[email protected]> > Cc: [email protected] > > [email protected] (Ludovic Courtès) writes: > > "Bertalan Fodor (LilyPondTool)" <[email protected]> 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
