all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Ted Zlatanov <tzz@lifelogs.com>
To: help-gnu-emacs@gnu.org
Subject: Re: plists, alists, and hashtables
Date: Wed, 05 Aug 2015 16:08:48 -0400	[thread overview]
Message-ID: <87k2t9bir3.fsf@lifelogs.com> (raw)
In-Reply-To: mailman.7856.1438803631.904.help-gnu-emacs@gnu.org

On Wed, 05 Aug 2015 20:40:21 +0100 Robert Thorpe <rt@robertthorpeconsulting.com> wrote: 

RT> As Pascal mentioned, we only have a very small number of characters left
RT> to use for read syntax.

RT> You can't just consider one proposal alone.  Just because something is
RT> useful doesn't mean that it's useful enough to burn a character or two
RT> for.  It has to be compared to alternatives.

OK, I understand your viewpoint.  My goal is not to burn characters but
to make it easy to create a map in ELisp.

RT> There may be alternatives though.  For example, instead of:
RT> #s(hash-table size 65 test eql rehash-size 1.5 rehash-threshold 0.8 data ())

RT> We could have a shorthand, perhaps #s(h data)

That's all right, but I would probably prefer a Unicode pair of
characters.  In 2015, that's going to inconvenience very few people.

RT> Like Pascal I think alists are generally a good idea.  People who don't
RT> understand the performance implications of them won't understand those
RT> of hash-maps either.  Especially when things are done per key.

RT> In an editor the vast majority of maps are likely to contain only a few
RT> variables.  A few years ago I made a program that examined every Emacs
RT> variable that ended in "alist".  Almost all of them were short.  Only a
RT> handful were long enough to cause performance issues.

I see what you mean. The benefit to the users who use a hypothetical new
map syntax would be mostly code readability, because alists and plists
are not as readable as a true map syntax.  Is that enough to justify it?
If it's not obtrusive and doesn't burn reader characters, I think so.

So as a first cut, maybe «(k1 . v1) (k2 . v2)» and ««(k1 . v1) (k2 .
v2)»» would be a good syntax (equal and eql versions respectively),
simply converted to the appropriate #s(hash-table ...) syntax?

RT> If a hash-map type were used then there could be a bit to signify if
RT> it's *really* a hash.  I've heard that some of the scripting languages
RT> are doing this because they've found what I found; that most maps
RT> contain so few elements that hashing just makes things slower.  But, the
RT> bit would have to be tested before every map operation.

I think the bit check performance penalty would be insignificant, and
that the backend implementation can adapt to use lists for small maps.
In any case, using these would be voluntary, people can still use the
usual alists and plists.

Ted


       reply	other threads:[~2015-08-05 20:08 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.7856.1438803631.904.help-gnu-emacs@gnu.org>
2015-08-05 20:08 ` Ted Zlatanov [this message]
2015-08-05 20:45   ` plists, alists, and hashtables Stefan Monnier
2015-08-05 21:36   ` Drew Adams
2015-08-05 21:41   ` Pascal J. Bourguignon
     [not found]   ` <mailman.7860.1438807554.904.help-gnu-emacs@gnu.org>
2015-08-06  1:32     ` Ted Zlatanov
     [not found]   ` <mailman.7862.1438810623.904.help-gnu-emacs@gnu.org>
2015-08-06  1:36     ` Ted Zlatanov
2015-07-31 21:42 How to iterate over properties in a plist? Marcin Borkowski
2015-07-31 22:18 ` Stefan Monnier
     [not found]   ` <mailman.7705.1438381807.904.help-gnu-emacs@gnu.org>
2015-07-31 23:33     ` Pascal J. Bourguignon
     [not found]       ` <mailman.7750.1438469396.904.help-gnu-emacs@gnu.org>
2015-08-04 10:15         ` plists, alists, and hashtables (was: How to iterate over properties in a plist?) Ted Zlatanov
     [not found]           ` <mailman.7809.1438684158.904.help-gnu-emacs@gnu.org>
2015-08-04 11:23             ` plists, alists, and hashtables Ted Zlatanov
2015-08-05  4:36           ` plists, alists, and hashtables (was: How to iterate over properties in a plist?) Rusi
2015-08-05  6:12             ` plists, alists, and hashtables Pascal J. Bourguignon
2015-08-05  9:47               ` Ted Zlatanov
2015-08-05 12:20                 ` Rusi
2015-08-06 19:16                   ` Stefan Monnier
     [not found]                   ` <mailman.7892.1438888819.904.help-gnu-emacs@gnu.org>
2015-08-07 16:33                     ` Rusi
2015-08-05 17:24                 ` Pascal J. Bourguignon
2015-08-05 18:31                   ` Ted Zlatanov
2015-08-05 19:30                     ` Barry Margolin
2015-08-05 19:40                     ` Robert Thorpe
2015-08-05 21:11                     ` Pascal J. Bourguignon
2015-08-06 15:17                       ` Ted Zlatanov
2015-08-06 18:46                         ` Pascal J. Bourguignon
2015-08-06 20:19                           ` Drew Adams
2015-08-06 21:08                           ` Ted Zlatanov
2015-08-07  0:23                             ` Pascal J. Bourguignon
2015-08-06 19:35                         ` Stefan Monnier
2015-08-05 13:48               ` Drew Adams
2015-08-06 19:12           ` Stefan Monnier
     [not found]           ` <mailman.7890.1438888393.904.help-gnu-emacs@gnu.org>
2015-08-06 20:00             ` Pascal J. Bourguignon
2015-08-06 20:57             ` Ted Zlatanov
2015-08-06 21:10               ` Drew Adams
     [not found]               ` <mailman.7902.1438895429.904.help-gnu-emacs@gnu.org>
2015-08-06 21:15                 ` Ted Zlatanov
2015-08-06 21:31               ` Stefan Monnier
2015-08-07  1:53                 ` Ted Zlatanov
2015-08-07  7:34                   ` Pascal J. Bourguignon
2015-08-07 16:32                   ` Stefan Monnier
     [not found]                   ` <mailman.7941.1438965165.904.help-gnu-emacs@gnu.org>
2015-08-08  3:48                     ` Pascal J. Bourguignon
2015-08-08 13:42                       ` Stefan Monnier
2015-08-08 14:51                         ` Rusi
2015-08-07  0:08               ` Pascal J. Bourguignon
2015-08-07  2:14                 ` Ted Zlatanov
2015-08-07  7:53                   ` Pascal J. Bourguignon
2015-08-07 11:21                     ` Ted Zlatanov
2015-08-07 11:47                       ` Pascal J. Bourguignon
2015-08-07 17:21                         ` Ted Zlatanov
2015-08-07 19:21                           ` Stefan Monnier
     [not found]                           ` <mailman.7952.1438975314.904.help-gnu-emacs@gnu.org>
2015-08-08  3:52                             ` Pascal J. Bourguignon
2015-08-07 16:35                       ` Stefan Monnier

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=87k2t9bir3.fsf@lifelogs.com \
    --to=tzz@lifelogs.com \
    --cc=help-gnu-emacs@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.