From: Michael Heerdegen <michael_heerdegen@web.de>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: 25929@debbugs.gnu.org, Nicolas Petton <nicolas@petton.fr>,
Tino Calancha <tino.calancha@gmail.com>
Subject: bug#25929: 25.2; map-delete doesn't delete permanently 1st alist elt
Date: Sat, 04 Mar 2017 01:04:18 +0100 [thread overview]
Message-ID: <87efydlxfh.fsf@drachen> (raw)
In-Reply-To: <jwvbmtjwwdn.fsf-monnier+emacsbugs@gnu.org> (Stefan Monnier's message of "Thu, 02 Mar 2017 10:12:09 -0500")
Stefan Monnier <monnier@iro.umontreal.ca> writes:
> > (macroexp-let2 nil key
> > `(progn
> > (map--dispatch ,map
> > :list (setf (alist-get ,key ,map nil t) nil)
> > :hash-table (remhash ,key ,map)
> > :array (and (>= ,key 0)
> > (<= ,key (seq-length ,map))
> > (aset ,map ,key nil)))
> > ,map)))
>
> Note that this will make it pretty much impossible to use
> cl-generic dispatch.
It will also break cases where MAP is an expression that is not a
symbol:
#+begin_src emacs-lisp
(let ((thing (cons 'tag (list (cons 0 1) (cons 2 3)))))
(map-delete (cdr thing) 0))
==> nil
(map-delete (list (cons 0 1) (cons 2 3)) 0)
==> if: Symbol's function definition is void: \(setf\ list\)
#+end_src
> A better option might be to provide a map-remove which works
> functionally (i.e. doesn't modify its argument by side-effects), and
> then change map-delete to signal an error when we ask to delete the
> first element of the list (and to stop returning the "new map" since
> it just works imperatively instead).
Why not make it just like `delete': return the map with the entry
removed, the original map might be altered - that's it.
If you want to assign the result back to a symbol/place, use setf or
callf. Any unnecessary magic just blows up the semantics.
With other words, I would fix this issue by altering the docstring
("return the result" instead of "return MAP") - or am I missing
something?
Michael.
next prev parent reply other threads:[~2017-03-04 0:04 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-02 7:17 bug#25929: 25.2; map-delete doesn't delete permanently 1st alist elt Tino Calancha
2017-03-02 8:56 ` Nicolas Petton
2017-03-02 10:59 ` Nicolas Petton
2017-03-02 11:30 ` Tino Calancha
2017-03-02 12:27 ` Nicolas Petton
2017-03-02 12:34 ` Nicolas Petton
2017-03-02 13:34 ` Tino Calancha
2017-03-02 15:12 ` Stefan Monnier
2017-03-04 0:04 ` Michael Heerdegen [this message]
2017-03-04 0:16 ` Michael Heerdegen
2017-03-21 20:41 ` Lars Ingebrigtsen
2017-03-22 11:55 ` Michael Heerdegen
2017-03-22 12:01 ` Lars Ingebrigtsen
2017-03-22 12:56 ` Noam Postavsky
2017-03-22 13:31 ` Lars Ingebrigtsen
2017-03-22 14:43 ` Michael Heerdegen
2017-03-22 17:04 ` Stefan Monnier
2017-03-22 17:23 ` Lars Ingebrigtsen
2017-03-22 20:31 ` Stefan Monnier
2017-03-22 17:02 ` Stefan Monnier
2017-03-29 15:25 ` bug#25929: 25.2; plists and map-* Lars Ingebrigtsen
2017-03-29 15:36 ` Nicolas Petton
2017-03-21 11:35 ` bug#25929: 25.2; map-delete doesn't delete permanently 1st alist elt Nicolas Petton
2017-03-21 15:11 ` Stefan Monnier
2017-03-21 18:06 ` Nicolas Petton
2017-03-21 20:29 ` Stefan Monnier
2017-04-26 7:58 ` Nicolas Petton
2017-03-02 12:36 ` npostavs
2017-03-02 12:45 ` Nicolas Petton
2022-04-26 13:34 ` Lars Ingebrigtsen
2022-04-28 3:17 ` Richard Stallman
2022-04-28 16:00 ` Drew Adams
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=87efydlxfh.fsf@drachen \
--to=michael_heerdegen@web.de \
--cc=25929@debbugs.gnu.org \
--cc=monnier@iro.umontreal.ca \
--cc=nicolas@petton.fr \
--cc=tino.calancha@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.