[Top][All Lists]

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

Re: [ELPA] New package: hap.el

From: Tino Calancha
Subject: Re: [ELPA] New package: hap.el
Date: Thu, 2 Mar 2017 15:02:32 +0900 (JST)
User-agent: Alpine 2.20 (DEB 67 2015-01-07)

On Wed, 1 Mar 2017, Stefan Monnier wrote:

It might be convenient to group together under same file all these
related operations.  Thus, I'd like to add this file to Elpa (or Emacs
core, whatever is appropiate), in case people think it's useful.

Would it make sense to add this to map.el?
That is a good idea.  Some part fit well.
At least the conversion between alist and hash-tables is already in
map.el under the name `map-into`.
In hap.el, optionally, you can convert from alist to hash table,
so that:
(let ((map '((1 . a) (1 . foo) (2 . b))))
   (alist-get 1 map)
   (gethash 1 (map-into map 'hash-table))))
=> t

Maybe map.el might offer same thing.
I think that is important.
One of the reasons to convert alist to hash table might be
that the size of the alist became large.  Under such assumption,
you might want to use a hash table to do faster queries.  In case
you have duplicated keys in the alist you'd get the wrong results.

We might add a new function `map-equal' that return true when
MAP1 and MAP2 have same type and data; for hash tables we might compare the properties as well.

map.el currently doesn't accommodate plists, but maybe that can be fixed
(e.g. by checking (consp (car map)) and/or by adding a few
functions specially designed for plists).
We might do plist-get setf-able as it was done for alist-get.

reply via email to

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