unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Thien-Thi Nguyen <ttn@glug.org>
Subject: Re: How to populate a property list?
Date: 30 Oct 2004 19:12:54 +0200	[thread overview]
Message-ID: <7ezn243zah.fsf@ada2.unipv.it> (raw)
In-Reply-To: M_GdnWcNqdG0GR7cRVn-gw@speakeasy.net

Hattuari <susudata@setidava.kushan.aa> 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	other threads:[~2004-10-30 17:12 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-10-26 10:09 How to populate a property list? Hattuari
2004-10-26 12:28 ` Thien-Thi Nguyen
2004-10-27 20:38   ` Hattuari
2004-10-31 14:39     ` Kai Grossjohann
2004-10-26 15:24 ` Kevin Rodgers
2004-10-30 12:05   ` Hattuari
2004-10-30 17:12     ` Thien-Thi Nguyen [this message]
2004-10-30 17:54       ` Hattuari
2004-10-30 20:17         ` Thien-Thi Nguyen
2004-10-31  8:32           ` Hattuari
2004-10-31  8:57             ` Thien-Thi Nguyen
2004-10-31 15:23             ` Hattuari
2004-11-01 16:44         ` Kevin Rodgers
2004-10-31 14:36 ` Kai Grossjohann

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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7ezn243zah.fsf@ada2.unipv.it \
    --to=ttn@glug.org \
    /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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).