From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Vibhav Pant <vibhavp@gmail.com>
Cc: "emacs-devel@gnu.org" <emacs-devel@gnu.org>
Subject: Re: [PATCH] json: Add support for encoding structs
Date: Thu, 27 Apr 2017 08:31:08 -0400 [thread overview]
Message-ID: <jwvshkurq6l.fsf-monnier+Inbox@gnu.org> (raw)
In-Reply-To: <CA+T2Sh1RGN4g5JO-nL6sNZ1Exex8e6MkC3EqjqKqL2=jEYRbhQ@mail.gmail.com> (Vibhav Pant's message of "Thu, 27 Apr 2017 12:20:35 +0530")
>> FWIW, while you can make this work, I think it's a bad API: Elisp
>> usually behaves like "an absent argument is equivalent to nil", and it's
>> easier for the coder if we stick to this behavior (also, occasionally
>> it's handy to be able to use ":key nil" in order not to pass :key).
> Fair point, I was thinking that slot opts aren't exactly an API, so this
> was an exception.
That's the point: it would be an exception.
There are a few places where we distinguish "absence" from nil, and in
my experience these are better avoided.
>>> IIRC, the empty string is a valid JSON key (`JSON.parse(`{"":1}`)`
>>> works in JS). Symbols are also considered a valid type according to
>>> `json-encode-key'.
>> I don't see why that forces us to also accept symbols here.
> Wouldn't it be consistent to allow symbols in both `json-encode' and
> `json-encode-key`?
I don't see how that's relevant: we're talking about the thing that
follows :json (or somesuch) in a cl-defstruct, not a call to some json
encoding function.
Stefan
next prev parent reply other threads:[~2017-04-27 12:31 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-23 10:16 [PATCH] json: Add support for encoding structs Vibhav Pant
2017-04-24 13:25 ` Ted Zlatanov
2017-04-24 17:54 ` Vibhav Pant
2017-04-24 19:17 ` Ted Zlatanov
2017-04-24 21:00 ` Ted Zlatanov
2017-04-24 21:43 ` Stefan Monnier
2017-04-25 14:26 ` Ted Zlatanov
2017-04-25 16:26 ` Vibhav Pant
2017-04-25 18:12 ` Ted Zlatanov
2017-04-26 12:13 ` Stefan Monnier
2017-04-27 6:50 ` Vibhav Pant
2017-04-27 12:31 ` Stefan Monnier [this message]
2017-04-25 12:27 ` Vibhav Pant
2017-04-24 22:52 ` Davis Herring
2017-04-25 12:40 ` Vibhav Pant
2017-04-24 13:45 ` Clément Pit-Claudel
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=jwvshkurq6l.fsf-monnier+Inbox@gnu.org \
--to=monnier@iro.umontreal.ca \
--cc=emacs-devel@gnu.org \
--cc=vibhavp@gmail.com \
/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.