From: Barry OReilly <gundaetiapo@gmail.com>
To: sdl.web@gmail.com, emacs-devel@gnu.org
Subject: Re: Fix nreverse
Date: Wed, 21 May 2014 10:07:45 -0400 [thread overview]
Message-ID: <CAFM41H1P8rB0JKfuXmydEOm4vWKnx-JesXUVEKvbqPLSR04X0Q@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 904 bytes --]
> I also fix nreverse doc-string not to mention its implementation
> details.
That the sequence is mutated is not an implementation detail. It is a
side effect that should be documented as part of the interface.
(let ((lst '(1 2 3)))
(message "Reversed: %s" (reverse lst))
(message "Original: %s" lst)
(message "NReversed: %s" (nreverse lst))
(message "Original: %s" lst))
;; Output:
;; Reversed: (3 2 1)
;; Original: (1 2 3)
;; NReversed: (3 2 1)
;; Original: (1)
The user may well care about the difference.
> This would make nreverse and reverse symmetric.
(let ((str "123"))
(message "Reversed: %s" (reverse str))
(message "Original: %s" str)
(message "NReversed: %s" (nreverse str))
(message "Original: %s" str))
;; Output:
;; Reversed: 321
;; Original: 123
;; NReversed: 321
;; Original: 123
This is not symmetrical to the lst example.
[-- Attachment #2: Type: text/html, Size: 1177 bytes --]
next reply other threads:[~2014-05-21 14:07 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-21 14:07 Barry OReilly [this message]
2014-05-21 17:17 ` Fix nreverse Stefan Monnier
2014-05-22 0:15 ` Leo Liu
-- strict thread matches above, loose matches on Subject: below --
2014-05-21 2:20 Leo Liu
2014-05-21 2:53 ` Stefan Monnier
2014-05-21 4:06 ` Leo Liu
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=CAFM41H1P8rB0JKfuXmydEOm4vWKnx-JesXUVEKvbqPLSR04X0Q@mail.gmail.com \
--to=gundaetiapo@gmail.com \
--cc=emacs-devel@gnu.org \
--cc=sdl.web@gmail.com \
/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.