all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* plist-put: destructive?
@ 2017-01-20 19:13 Eric Abrahamsen
  2017-01-21  3:25 ` Stefan Monnier
  2017-01-21  8:13 ` tomas
  0 siblings, 2 replies; 14+ messages in thread
From: Eric Abrahamsen @ 2017-01-20 19:13 UTC (permalink / raw)
  To: help-gnu-emacs

Plists are great, except for setting keys, which isn't great.
Occasionally it annoys me enough to want to try to "do something" about
it.

The docstring for plist-put says we should be using:

(setq some-plist (plist-put some-plist :prop val))

To be sure of modifying the list correctly. But all my experiments have
shown that a plain plist-put does modify the original list, and
everything works as expected without re-assigning to the original
variable.

So what's the ambiguity? Are there circumstances where a simple
plist-put isn't going to modify the original plist?

I tried this:

(gv-define-simple-setter plist-get plist-put)

Which allows this to work:

(setf (plist-get some-plist :prop) val)

That's hardly less verbose than the setq re-assignment, but I suppose it
would allow for a plist to be used in cl-letf, or for a custom macro
like:

(with-plist-props ((prop1 :prop1) (prop2 :prop2)) some-plist
  ...)

But if plist-put is reliably destructive, I don't suppose any of that is
really necessary.

Can we rely on plist-put?

Thanks,
Eric




^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2017-01-23  9:01 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-01-20 19:13 plist-put: destructive? Eric Abrahamsen
2017-01-21  3:25 ` Stefan Monnier
2017-01-21 10:25   ` tomas
2017-01-21 16:41   ` Eric Abrahamsen
2017-01-21 17:13     ` Drew Adams
2017-01-22  0:50       ` Eric Abrahamsen
2017-01-22 10:08         ` Philipp Stephani
2017-01-22 13:10           ` Eric Abrahamsen
2017-01-22 17:30         ` Stefan Monnier
2017-01-23  0:31           ` Eric Abrahamsen
2017-01-23  9:01           ` tomas
2017-01-21 23:03     ` Stefan Monnier
2017-01-22  1:15       ` Eric Abrahamsen
2017-01-21  8:13 ` tomas

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.