From: Philipp Stephani <p.stephani2@gmail.com>
To: "João Távora" <joaotavora@gmail.com>
Cc: Yuri Khan <yurivkhan@gmail.com>, Emacs developers <emacs-devel@gnu.org>
Subject: Re: [PATCH] Accept plists when serializing and parsing JSON
Date: Sat, 2 Jun 2018 10:04:55 +0200 [thread overview]
Message-ID: <CAArVCkTYP8UbzgeEKL7dHp3ymoL9Za2QpOrx0COaqMJBY1WDdw@mail.gmail.com> (raw)
In-Reply-To: <87in75bjvm.fsf@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 3726 bytes --]
João Távora <joaotavora@gmail.com> schrieb am Mi., 30. Mai 2018 um
10:58 Uhr:
> Yuri Khan <yurivkhan@gmail.com> writes:
>
> > On Wed, May 30, 2018 at 5:31 AM João Távora <joaotavora@gmail.com>
> wrote:
> >
> >> Well, it's not really "global state" in the sense I believe you're
> >> talking about, because no part of the library is maintaining any state
> in
> >> global variables -- it's read-only from json.c.
>
> > after ironing out all [the other?] bugs related to shared state
>
> Which ones? Those seem to be precisely the ones I meant to say are
> excluded because the var is read-only.
>
It is not read-only. If it were read-only, it would be just a constant and
not a variable (in the imperative programming sense) at all.
>
> > * ‘foo’ wants plists while ‘bar’ wants alists.
>
> If "want" is the same thing as "must have", then bar should be setting
> the var from the beginning, end of story. It should only not set the var
> if it doesn't care.
>
(Almost) every caller cares about the return type of the function call;
what else should it care about? That means that every caller would have to
set this variable, turning it into a parameter, just with awkward syntax
and subtle, easy-to-get-wrong interface.
>
> There are many variables like this in emacs.
Yes, unfortunately. That's no reason to introduce new ones.
Emacs was written in simpler times (the 1970s?) when the amount of code in
the world was much smaller and people didn't yet know everything that we
now know about software engineering. That's OK; if you look at Fortran code
from that era it also looks very different from what people would write
today (six-letter function names, a single static callback function,
customization happens generally by copying and modifying functions, ...).
But we have 2018, so we should apply the accumulated wisdom from the last
decades.
> Eli recently reminded me in
> a closely related thread I have to bind coding-system-for-write around
> process-send-string, for example.
>
Yes, that's necessary because the existing interface of process-send-string
uses dynamic variables as hidden parameters. That's unfortunate, but no
reason why other, unrelated APIs should also do that.
>
> Obviously, the pitfall is overlooking to bind them when you have
> to. Presumably this is outweighed by the convenience of not passing a
> trillion args to a function call and, more importantly, to every caller
> of a function, like in the commit that removes the var, which is quite a
> bit more complex (which is why I started with the other alternative).
>
No, it's never outweighted. If there are too many parameters, you'd
collecting them in an "options" object and pass that around, or create a
"JsonDecoder" object that keeps the settings, etc.
>
> Anyway, this point could be irrelevant if we remove the variable and
> argument completely, auto-detecting plists.
Can't decide if that could
> be a worse idea, though.
>
>
It might be because it could make the interface more surprising. There's a
clear type difference between hashtables and lists, so detecting them
automatically is fine. But "plist" isn't really a type; there's no
fundamental difference between plists and alists, and the only difference
is how they are used (assq vs. plist-get etc.). That's one of the (several)
reasons why I decided to not support plists in json.c at all, and I'm still
not convinced it's worth the additional interface complexity (for
deserializing the story is probably different, as it doesn't make the
existing interface more complex, and with the CL argument lists you already
have an actual use case).
[-- Attachment #2: Type: text/html, Size: 5162 bytes --]
next prev parent reply other threads:[~2018-06-02 8:04 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-29 14:59 [PATCH] Accept plists when serializing and parsing JSON João Távora
2018-05-29 21:20 ` Philipp Stephani
2018-05-29 22:03 ` João Távora
2018-05-30 6:37 ` Yuri Khan
2018-05-30 8:58 ` João Távora
2018-06-02 8:04 ` Philipp Stephani [this message]
2018-06-03 0:34 ` João Távora
2018-06-03 4:05 ` Stefan Monnier
2018-06-03 13:43 ` João Távora
2018-06-02 7:45 ` Philipp Stephani
2018-06-02 7:39 ` Philipp Stephani
2018-06-01 9:39 ` Eli Zaretskii
2018-06-01 23:29 ` João Távora
2018-06-02 6:55 ` Eli Zaretskii
2018-06-02 8:24 ` Philipp Stephani
2018-06-02 9:00 ` Eli Zaretskii
2018-06-02 16:46 ` Philipp Stephani
2018-06-02 19:18 ` Eli Zaretskii
2018-06-08 14:45 ` Eli Zaretskii
2018-06-02 8:30 ` Philipp Stephani
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=CAArVCkTYP8UbzgeEKL7dHp3ymoL9Za2QpOrx0COaqMJBY1WDdw@mail.gmail.com \
--to=p.stephani2@gmail.com \
--cc=emacs-devel@gnu.org \
--cc=joaotavora@gmail.com \
--cc=yurivkhan@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 public inbox
https://git.savannah.gnu.org/cgit/emacs.git
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).