[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: plist-put modification by side effect

From: Helmut Eller
Subject: Re: plist-put modification by side effect
Date: Sat, 31 Jan 2009 23:46:58 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux)

* Dan Davison [2009-01-31 22:06+0100] writes:

> ,----[C-h f plist-put]
> | plist-put is a built-in function in `C source code'.
> | (plist-put plist prop val)
> | 
> | Change value in plist of prop to val.
> | plist is a property list, which is a list of the form
> | (PROP1 VALUE1 PROP2 VALUE2 ...).  prop is a symbol and val is any object.
> | If prop is already a property on the list, its value is set to val,
> | otherwise the new prop val pair is added.  The new plist is returned;
> | use `(setq x (plist-put x prop val))' to be sure to use the new value.
> | The plist is modified by side effects.
> | 
> `----
> I don't get this. It says the plist is altered by side effects. So
> what's with the "but just to be extra careful use (setq ...)"  advice?
> I think I've seen a similar statemenmt in other docstrings, but I
> can't remember which. Is there some subtlety that means you can't
> actually rely on the side effect? Surely not?

If the list is nil, there is nothing to be modified and plist-put
allocates a new list instead.  In this case you must assign the returned
value.  The same situation occurs with the delete function when the list
would be empty after the removing all elements.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]