emacs-devel
[Top][All Lists]
Advanced

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

Re: [PATCH] Accept plists when serializing and parsing JSON


From: João Távora
Subject: Re: [PATCH] Accept plists when serializing and parsing JSON
Date: Sun, 03 Jun 2018 01:34:49 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

Philipp Stephani <address@hidden> writes:

> (a 1 b 2) gets serialized to {"a": 1, "b": 2} and then might reasonably
> conclude that (a 1 :a 2) gets serialized to {"a": 1, ":a": 2}, but that
> would be wrong. It's more obvious and easier to understand to not treat
> colons specially.

I think we should do what json.el does here. It's doing otherwise that
would confuse people.

>>   char *keyword_key_str = SAFE_ALLOCA (1 + strlen(key_str) + 1);
>>   keyword_key_str[0]=':';
> Again, no special treatment for colons please.

No. Because this would, with no obvious reason , defeat the main purpose
of making plists, which is to use them in destructuring lambda lists,
such as the one you yourself chose for json-parse-string.

Regarding the doc comments, I'll do my best to rephrase and use
consistent commas. I'll also add the test you suggested as well.

>>>> 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.

Read some 5 lines above and you will see that what I meant, and indeed
wrote, it's "read-only from json.c"". You may hold another
interpretation, and that's just fine, but by "global state", in Emacs, I
understand things like buffer, point, mark, match data, etc... That is,
I mean exactly what Emacs adds to these functions' docstrings. From
help-fns.el

  (when (or (function-get function 'pure)
            (function-get function 'side-effect-free))
          (insert "\nThis function does not change global state, "
                  "including the match data."))

This is what I mean by global state. Anything else is potentially
erudite bikeshedding in which I'm not particularly interested right now.

>  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

I really don't think of programmers of the 70's as these simpletons,
quite the contrary actually. Certainly the best programming paradigms
IMHO are those started around that time, in Common Lisp for example,
where dynamic variables abound. But as I write this, I feel the
trappings another bikeshed starting to materialize so I must say that's
just, like, my opinion, man.

João




reply via email to

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