[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#40693: 28.0.50; json-encode-alist changes alist
From: |
Basil L. Contovounesios |
Subject: |
bug#40693: 28.0.50; json-encode-alist changes alist |
Date: |
Sat, 23 May 2020 23:41:20 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
João Távora <joaotavora@gmail.com> writes:
> "Basil L. Contovounesios" <contovob@tcd.ie> writes:
>
>> João Távora <joaotavora@gmail.com> writes:
>>> "Basil L. Contovounesios" <contovob@tcd.ie> writes:
>
>> 0. bar.el does not use lexical-binding.
>> 1. The second lambda in forty-two does not let-bind foo-42.
>> 2. If you byte-compile bar.el with bar-have-native-42 set to t, and then
>> load bar.elc in an Emacs that has bar-have-native-42 set to nil, then
>> 42.0 gets printed, which is wrong. This is due to the incorrect
>> usage of eval-when-compile: we want the check to happen at runtime as
>> well.
>
> I think you mean load-time.
Yes.
> Anyway, this is true if you want 27.1 elc's to be loadable in 26.x.
It is also true if you want version N .elc files to be loadable in
version N. The problems I list are not specific to either JSON or
inter-Emacs-version compat.
> I was labouring under the impression that we don't care about that
> (and this is why I thought of the macro approach). Do we? The source
> file is compatible between multiple emacs version, but is the
> byte-compiled file also compatible?
This isn't (primarily) about 26/27 compat, but about supporting
--without-json configurations properly. In the examples I've given so
far I was exclusively using Emacs master --with-json, hence the
(fset 'json-parse-buffer nil). Native JSON functions are not guaranteed
to be available in any version of Emacs to date, just like D-Bus or X.
The only benefit of the macro approach is zero overhead - no fboundp
checks at load time, and no indirection in calling jsonrpc--json-read.
But those should be negligible costs, and macros come with their slew of
drawbacks that makes them unnecessary in this simple case.
>>> No idea how to check if byte-code is "valid" or not: I just check the
>>> warnings. Can you tell me?
>>
>> 0. emacs -Q -batch -f batch-byte-compile foo.el
>> 1. emacs -Q
>> 2. (fset 'json-parse-buffer nil) C-j
>> 3. M-x load-file RET foo.elc RET
>> 4. (disassemble 'foo) C-j
>
> Thanks.
>
>> I think the declarations make the intention explicit to both the reader
>> and the byte-compiler in a simple way, without wrestling the
>> eval-*-compile machinery or allowing for subtle bugs like the ones
>> above.
>
> The problem, of course, is that you're repeating yourself, a maintenance
> hazard. Not too big in this case.
Agreed.
--
Basil
- bug#40693: 28.0.50; json-encode-alist changes alist, Basil L. Contovounesios, 2020/05/17
- bug#40693: 28.0.50; json-encode-alist changes alist, Eli Zaretskii, 2020/05/18
- bug#40693: 28.0.50; json-encode-alist changes alist, Dmitry Gutov, 2020/05/18
- bug#40693: 28.0.50; json-encode-alist changes alist, João Távora, 2020/05/18
- bug#40693: 28.0.50; json-encode-alist changes alist, Basil L. Contovounesios, 2020/05/21
- bug#40693: 28.0.50; json-encode-alist changes alist, João Távora, 2020/05/21
- bug#40693: 28.0.50; json-encode-alist changes alist, Basil L. Contovounesios, 2020/05/22
- bug#40693: 28.0.50; json-encode-alist changes alist, João Távora, 2020/05/22
- bug#40693: 28.0.50; json-encode-alist changes alist, Basil L. Contovounesios, 2020/05/23
- bug#40693: 28.0.50; json-encode-alist changes alist, João Távora, 2020/05/23
- bug#40693: 28.0.50; json-encode-alist changes alist,
Basil L. Contovounesios <=
- bug#40693: 28.0.50; json-encode-alist changes alist, João Távora, 2020/05/23