From: Ted Zlatanov <tzz@lifelogs.com>
To: help-gnu-emacs@gnu.org
Subject: Re: plists, alists, and hashtables
Date: Thu, 06 Aug 2015 22:14:24 -0400 [thread overview]
Message-ID: <87h9obsv3z.fsf@lifelogs.com> (raw)
In-Reply-To: 87h9ocm02t.fsf@kuiper.lan.informatimago.com
On Fri, 07 Aug 2015 02:08:58 +0200 "Pascal J. Bourguignon" <pjb@informatimago.com> wrote:
PJB> Ted Zlatanov <tzz@lifelogs.com> writes:
>> Maybe the macro is good enough, but I think the keys and values have to
>> be clearly separated from each other and from other cells to make it
>> visually useful.
PJB> I understand that, and I cannot advise more strongly that you add
PJB> newlines and indent your data to clearly show it.
PJB> (hash-table k1 v1
PJB> kkkk2 v2
PJB> k3 vvvvvv3)
I don't think it's good to force the programmer to reformat their code
because the syntax doesn't do the right thing.
PJB> Also, I would admit that using parentheses around the entries could help
PJB> editing the data structure, since that allows adding or removing entries
PJB> easily with a structural editor like emacs+paredit.
PJB> (mhash-table (k1 v1)
PJB> (kkkk2 v2)
PJB> (k3 vvvvvv3))
PJB> It works well enough for a macro (eg. let), but for a function it is a
PJB> real bother
I think that's good enough in the `let' format, as a macro. The
syntactic shortcut of creating keys without a cell with a null value is
nice too. Can we agree that this is a good syntax and move back to
discussing Unicode markers again? :)
>> The second part of my question was whether Customize support for
>> hashtables would make them more approachable and useful.
PJB> This could definitely help.
OK, I'm glad you agree. Maybe that discrete work would be generally
helpful regardless of the rest of this discussion.
PJB> Well, as mentionned before, if you abstract away a given type of maps:
PJB> - you may hide the costs, and that would lead to bad results,
PJB> - you would impose one kind of data structure usage (mutable hash or
PJB> immutable a-list or mutable a-lists or llrb-trees? etc)
PJB> - or if you don't and make it adaptative, we observe that there's
PJB> actually very little gain obtained, (because it takes time to convert
PJB> the data structures, and therefore it's hard to amortize that cost).
I see your point. It connects with Stefan's point about cons-ing alists
and plists because they're persistent. Thank you for stating it well.
PJB> If you don't believe that, you can always implement a library to provide
PJB> a common API over various dictionaries. I did just that in CL:
PJB> https://gitlab.com/com-informatimago/com-informatimago/blob/master/common-lisp/cesarum/dictionary.lisp
PJB> (sorry, I've not written the automatic adaptative code yet).
PJB> Let me just say that this is not the API I reach first when I write lisp
PJB> code. Just use a-lists or hash-tables directly, depending on the
PJB> circumstances determined at program-writting time.
OK, and your experience confirms the answer to my question. This is
very helpful to countermand my intuition, which is perhaps guided too
much by the other languages I use.
PJB> Notice that as mentionned before, the question here is whether that
PJB> should be included into the emacs lisp language, or whether that should
PJB> be defined as a user library.
PJB> As a user library nobody will say that it's a bad idea and that it
PJB> cannot have its usage in some program.
Yup, I understand. I'll look into making it.
PJB> And this is why we feel the lack of reader macros, since that would
PJB> clearly allow you to write a new syntax in a user library, instead of
PJB> having to beg it from the emacs lisp language itself.
Is this work already planned?
How much of it must be done to accomplish what I want, a library that
lets me say `{ "k1": "v1" }' (giving JSON syntax as an example) and
translates it to the correct #s(hash-table ...) serialization?
Together with the Customize support for hashtables, I think we can agree
these would be nice usability improvements.
Stefan also mentioned there could be performance optimizations for
hashtables themselves. I think that's a good direction too.
Ted
next prev parent reply other threads:[~2015-08-07 2:14 UTC|newest]
Thread overview: 55+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-31 21:42 How to iterate over properties in a plist? Marcin Borkowski
2015-07-31 22:18 ` Stefan Monnier
2015-07-31 22:29 ` Marcin Borkowski
2015-07-31 22:42 ` Dmitry Gutov
2015-08-01 13:34 ` Michael Heerdegen
[not found] ` <mailman.7705.1438381807.904.help-gnu-emacs@gnu.org>
2015-07-31 23:33 ` Pascal J. Bourguignon
2015-08-01 22:49 ` Stefan Monnier
[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
2015-08-04 10:29 ` Nicolas Petton
[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 [this message]
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
[not found] <mailman.7856.1438803631.904.help-gnu-emacs@gnu.org>
2015-08-05 20:08 ` Ted Zlatanov
2015-08-05 20:45 ` 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
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=87h9obsv3z.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.
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).