opensubscriber
   Find in this group all groups
 
Unknown more information…

e : emacs-devel@gnu.org 10 June 2012 • 8:11PM -0400

Re: Replacement for `aput' from obsolete assoc.el?
by Stephen J. Turnbull

REPLY TO AUTHOR
 
REPLY TO GROUP




Thien-Thi Nguyen writes:
> () Andreas Schwab <schwab@linu...>
> () Sat, 09 Jun 2012 11:46:38 +0200
>
>    "Stephen J. Turnbull" <stephen@xema...> writes:
>
>    > `plist-put' and `plist-get' are actually defined in C, but this shows
>    > how `memq' works well with plists:
>    >
>    > (defun plist-get (plist key)
>    >   (cadr (memq key plist)))
>
>    That fails if key is eq to a value.
>
> That is, a value closer to the plist head than the desired key.
> (If after, no worries.)

True, but of course it's a bug.  My bad.

In practice the idiom `(memq key plist)' is sometimes useful where
keys are guaranteed to be disjoint from values.  I shouldn't have
tried to overgeneralize.


Bookmark with:

Delicious   Digg   reddit   Facebook   StumbleUpon

Related Messages

opensubscriber is not affiliated with the authors of this message nor responsible for its content.