all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Stephen J. Turnbull" <stephen@xemacs.org>
To: emacs-devel@gnu.org
Subject: Re: plist-based package.el (was Re: cl-defstruct-based package.el, now with ert tests and no external tar!)
Date: Fri, 07 Jun 2013 12:07:44 +0900	[thread overview]
Message-ID: <87li6maa9r.fsf@uwakimon.sk.tsukuba.ac.jp> (raw)
In-Reply-To: <87fvwvwgg5.fsf@lifelogs.com>

Ted Zlatanov writes:
 > On Thu, 06 Jun 2013 18:30:11 +0900 "Stephen J. Turnbull" <stephen@xemacs.org> wrote: 
 > 
 > SJT> Ted Zlatanov writes:
 > >> plists as a sequence of odd=key and even=value don't actually associate
 > >> the key with the value, unlike hashtables and alists.
 > 
 > SJT> They do if you use plist-put and plist-get.  If you use list
 > SJT> primitives, you get what you deserve, which may not always be what you
 > SJT> want....
 > 
 > The association is positional.  All you have to do is insert an
 > element in the middle of the list and the plist is broken.

That's what I said, except more generally.  Really, one should pay
proper respect to venerable data structures.  They're often fragile.

 > Also there's no iteration primitive,

That's a bug in Emacs, not in plists as an ADT.  It would be easy
enough to add, and would be efficient (at least if written in C where
the obvious pointer-chasing algorithm is O(n), rather than in cl with
an O(n^2) algorithm!)

 > By contrast, an alist is an actual list of association cells

Actually, alists are just as bad, because neither keys nor values are
well-defined.  Key identity is ambiguous because of `assq', and value
identity is ambiguous because you don't know whether cdr or cadr (or
perhaps something more complex, such as (nth i item)) fetches the
value from the item.  If you make a mistake in your map function,
mapcar can become a weapon of mass destruction.  In a plist, on the
other hand, key and value are well-defined.

That, and the clean print representation, are why I strongly prefer
plists in APIs where the machine won't make mistakes -- once the bugs
are fixed -- but humans often have to write to that API.  Can't use a
hash table for that!  Well, you can, but interestingly enough, the
readable print representation of a hash table is built around a plist.

 > that works with `mapcar', and a hashtable is opaque so you don't
 > know or care how the association is maintained, but you can't screw
 > it up.

Aaahhhh, *hash* *tables*.  Now I like where you're headed!  An opaque
type, the modern programmer's heartthrob.  I have to agree with you
there.  "Opaque types are one honkin' great idea!  We should do more
of those."[1]



Footnotes: 
[1]  With apologies to Tim Peters.




  reply	other threads:[~2013-06-07  3:07 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-04 22:44 plist-based package.el (was Re: cl-defstruct-based package.el, now with ert tests and no external tar!) Daniel Hackney
2013-06-04 23:01 ` Dmitry Gutov
2013-06-05 14:53   ` Ted Zlatanov
2013-06-05 17:41     ` Stefan Monnier
2013-06-05 17:56       ` Drew Adams
2013-06-05 18:06         ` Ted Zlatanov
2013-06-06  9:30           ` Stephen J. Turnbull
2013-06-06 12:51             ` Ted Zlatanov
2013-06-07  3:07               ` Stephen J. Turnbull [this message]
2013-06-07 13:03                 ` opaque data types (was: plist-based package.el (was Re: cl-defstruct-based package.el, now with ert tests and no external tar!)) Ted Zlatanov
2013-06-07 13:27                   ` opaque data types Christopher Schmidt
2013-06-07 14:11                     ` Ted Zlatanov
2013-06-07 15:44                       ` Christopher Schmidt
2013-06-07 16:01                         ` Ted Zlatanov
2013-06-08  9:19                           ` Christopher Schmidt
2013-06-10  3:56                             ` Ted Zlatanov
2013-06-07 16:17                   ` Stefan Monnier
2013-06-07 17:48                     ` Ted Zlatanov
2013-06-08  6:11                   ` Stephen J. Turnbull
2013-06-08  6:28                   ` opaque data types [revise and resend] Stephen J. Turnbull
2013-06-10  4:00                     ` Ted Zlatanov
2013-06-05  1:34 ` plist-based package.el (was Re: cl-defstruct-based package.el, now with ert tests and no external tar!) Stefan Monnier
2013-06-06  1:31   ` Daniel Hackney
2013-06-08  6:47     ` Rand User

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

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

  git send-email \
    --in-reply-to=87li6maa9r.fsf@uwakimon.sk.tsukuba.ac.jp \
    --to=stephen@xemacs.org \
    --cc=emacs-devel@gnu.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.
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.