help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: How to populate a property list?


From: Thien-Thi Nguyen
Subject: Re: How to populate a property list?
Date: 30 Oct 2004 19:12:54 +0200
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50

Hattuari <address@hidden> writes:

> a plist has unique keys

only if constructed that way.

consider this *scratch* buffer snapshot:

  (setq x '(:k1 1 :k2 2 :k1 42))
  
  (plist-get x :k1)
  1
  
  (plist-get (cddr x) :k1)
  42

here, `(cddr x)' has unique keys, but `x' does not.  both have the plist
form (i.e., are amenable to passing to `plist-get' or being hung off a
symbol).  if you use `x' w/ assumption of unique keys, certain usage
patterns will end up hiding the second :k1 from you but not actually
recycling it.  result: unsightly (literally!) bloat.  e.g., continuing
from above:

  (setplist 'x x)
  (:k1 1 :k2 2 :k1 42)

  (get 'x :k1)
  1

  (put 'x :k1 "one")
  "one"
  
  (get 'x :k1)
  "one"
  
all's cool from `put' and `get' pov, right?  but the truth is deeper;
ignorance of it does not make it go away:

  x
  (:k1 "one" :k2 2 :k1 42)

thi


reply via email to

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