From: "Pascal J. Bourguignon" <pjb@informatimago.com>
To: help-gnu-emacs@gnu.org
Subject: Re: Elisps rplacd vs CL's one
Date: Sat, 29 Aug 2015 10:01:20 +0200 [thread overview]
Message-ID: <8737z2zfov.fsf@kuiper.lan.informatimago.com> (raw)
In-Reply-To: mailman.120.1440831791.19560.help-gnu-emacs@gnu.org
Marcin Borkowski <mbork@mbork.pl> 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
lisp:
http://www.informatimago.com/develop/lisp/com/informatimago/small-cl-pgms/intersection-r5rs-common-lisp-emacs-lisp/
http://www.informatimago.com/develop/lisp/com/informatimago/small-cl-pgms/intersection-r5rs-common-lisp-emacs-lisp/intersection-cl-el-r5rs.lisp
--
__Pascal Bourguignon__ http://www.informatimago.com/
“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
next parent reply other threads:[~2015-08-29 8:01 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <mailman.120.1440831791.19560.help-gnu-emacs@gnu.org>
2015-08-29 8:01 ` Pascal J. Bourguignon [this message]
2015-08-29 7:02 Elisps rplacd vs CL's one Marcin Borkowski
2015-08-29 22:05 ` Stefan Monnier
2015-08-30 4:51 ` Marcin Borkowski
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8737z2zfov.fsf@kuiper.lan.informatimago.com \
--to=pjb@informatimago.com \
--cc=help-gnu-emacs@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.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.