GNU bug report logs -
#40693
28.0.50; json-encode-alist changes alist
Previous Next
Reported by: Ivan Andrus <darthandrus <at> gmail.com>
Date: Sat, 18 Apr 2020 03:01:02 UTC
Severity: normal
Tags: fixed, patch
Found in version 28.0.50
Fixed in version 28.1
Done: "Basil L. Contovounesios" <contovob <at> tcd.ie>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
tags 40693 fixed
close 40693 28.1
quit
João Távora <joaotavora <at> gmail.com> writes:
> "Basil L. Contovounesios" <contovob <at> tcd.ie> writes:
>> The declarations are needed because the byte-compiler does not know that
>> loading json.el will e.g. define a dynamically bound variable
>> json-object-type and a nullary function symbol json-read. It therefore
>> not only complains but also generates invalid byte-code.
>
> Basil, I understand the need for the declarations, but I was suggesting
> something different. This, at the top, near all the other requires.
>
> (eval-and-compile
> (unless (fboundp 'json-parse-buffer)
> (require 'json)))
>
> and then do the defalias without the declarations below.
>
> (defalias blabla
> (if (fboundp 'json-parse-buffer)
> (lambda () json-c-things...)
> (lambda () json-el-things...)))
>
> Am I missing something or doesn't this work like you want?
There's a problem with the conditional require at byte-compile time. If
the version of Emacs doing the byte-compilation has native JSON support,
then it will generate invalid byte-code (and complain) for the case
where there is no native JSON support. In other words, there will be a
bug when an Emacs without native JSON loads a file that was
byte-compiled in an Emacs with native JSON.
> We're checking json.c function thrice instead of twice, but doesn't
> seem very bad, only a 50% increase :-)
Indeed, that wouldn't be an issue.
>> But I find this more heavy handed and intrusive, since it
>> unconditionally loads json.el during byte-compilation, even when
>> json-parse-buffer is available.
>
> I think the snippet above doesn't have this problem.
Indeed, but I think it suffers from the worse aforementioned problem.
> Anyway, this is a minor nitpick, push whatever you think is better.
Thanks. I've therefore gone with the original patch[1], as it exhibits
correct behaviour and is the least intrusive, but you should obviously
feel free to tweak it as you prefer.
[1]: Various json.el improvements
3f082af536 2020-05-22 15:16:13 +0100
https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=3f082af536c33ba713561e7ad4b691aaad488701
Thanks also to everyone who reviewed the patch.
I'm now closing this bug.
--
Basil
This bug report was last modified 5 years and 58 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.