[Top][All Lists]

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

Re: Elisps rplacd vs CL's one

From: Pascal J. Bourguignon
Subject: Re: Elisps rplacd vs CL's one
Date: Sat, 29 Aug 2015 10:01:20 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)

Marcin Borkowski <address@hidden> writes:

> Emacs Lisp's rplacd and Common Lisp's RPLACD are called the same, but
> behave differently (ELisp's one returns the NEWCDR and CL's one returns
> the modified cons).  What is the reason for that?  Is it an accident?
> While I do understand that EL ≠ CL, having a function called the same in
> both, doing roughly the same thing, but not quite, seems a bit
> misleading, and I was just curious whether there was a deep reason for
> that.

RPLACA in LISP 1.5 returned the CONS cell.  Common Lisp follows suit.

Notice that in CL, SETF should return the last value assigned (user
defined setters could break this convention). 

So in CL, (setf (car x) y) returns y
while     (rplaca x y)     returns x.

On the other hand, in emacs lisp:

    (let ((x (cons 1 2)))
      (list (setf (car x) 3)
            (rplaca x 3)))
    --> (3 3)

That would be the only reason I could imagine why the definition of
rplaca in emacs lisp has been thus changed, probably because when emacs
lisp was designed, lispers where too influenced by scheme and its bad
habit of renaming classic function and being incompatible with legacy
for no good reason, in general.

The gotchas between emacs lisp and Common Lisp are too numerous to make
a list.  And imagine that before Common Lisp, you had to deal with this
kind of problem about anytime you wanted to move a lisp program from one
machine to the other, because each machine had its own OS, with its own
specific lisp!  Happily, Common Lisp came. Unfortunately RMS didn't see
fit to follow the proceeding, and to upgrade emacs lisp to Common Lisp
when it was finally completed.

I prefer to concentrate on what's common between Common Lisp and emacs

__Pascal Bourguignon__       
“The factory of the future will have only two employees, a man and a
dog. The man will be there to feed the dog. The dog will be there to
keep the man from touching the equipment.” -- Carl Bass CEO Autodesk

reply via email to

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