* Elisps rplacd vs CL's one
@ 2015-08-29 7:02 Marcin Borkowski
2015-08-29 22:05 ` Stefan Monnier
0 siblings, 1 reply; 4+ messages in thread
From: Marcin Borkowski @ 2015-08-29 7:02 UTC (permalink / raw)
To: Help Gnu Emacs mailing list
Hi all,
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.
Best,
--
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Faculty of Mathematics and Computer Science
Adam Mickiewicz University
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Elisps rplacd vs CL's one
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
0 siblings, 1 reply; 4+ messages in thread
From: Stefan Monnier @ 2015-08-29 22:05 UTC (permalink / raw)
To: help-gnu-emacs
> 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.
FWIW, I consider the use of rplacd's return value to be a very bad idea.
Stefan
^ permalink raw reply [flat|nested] 4+ messages in thread
[parent not found: <mailman.120.1440831791.19560.help-gnu-emacs@gnu.org>]
* Re: Elisps rplacd vs CL's one
[not found] <mailman.120.1440831791.19560.help-gnu-emacs@gnu.org>
@ 2015-08-29 8:01 ` Pascal J. Bourguignon
0 siblings, 0 replies; 4+ messages in thread
From: Pascal J. Bourguignon @ 2015-08-29 8:01 UTC (permalink / raw)
To: help-gnu-emacs
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
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-08-30 4:51 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
[not found] <mailman.120.1440831791.19560.help-gnu-emacs@gnu.org>
2015-08-29 8:01 ` Pascal J. Bourguignon
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).