GNU bug report logs - #60311
json-available-p: make dynamically correct for Windows

Previous Next

Package: emacs;

Reported by: Mattias EngdegÄrd <mattias.engdegard <at> gmail.com>

Date: Sun, 25 Dec 2022 14:33:01 UTC

Severity: normal

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Mattias EngdegÄrd <mattias.engdegard <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 60311 <at> debbugs.gnu.org
Subject: bug#60311: json-available-p: make dynamically correct for Windows
Date: Mon, 26 Dec 2022 13:11:21 +0100
25 dec. 2022 kl. 16.40 skrev Eli Zaretskii <eliz <at> gnu.org>:

> Yes, you are right.  But please come up with a smaller changeset which
> only changes what strictly needs to be changed.  Or if you want, I can
> do this myself.

Since you have very specific ideas about how to go about it it's better that you make the change yourself. After all, attempts to remote-control someone else this way rarely make either party very happy.
As long as it gets done I'm not very particular about it myself.

>> +  (and (eval-when-compile (fboundp 'json-serialize))
>> +       ;; If `json--available-p' is present, we need to call it at run-time.
>> +       (or (not (eval-when-compile (fboundp 'json--available-p)))
>> +           (json--available-p))))
> 
> Btw, I don't understand this use of eval-when-compile here.  Can you
> explain why should we care at compile time whether these functions are
> fboundp?

Because we can: we already know the answers when subr.el is compiled, giving us constant nil or t values that will simplify the function to a constant or a call to json--available-p.

> why not just
> 
>  (and (fboundp 'json--available-p)
>       (json--available-p))

Calling `fboundp` at run time is wasteful, and that patch used the presence of json--available-p to indicate whether it needs to be called at run time (on Windows only, but it's good to keep that platform-dependency in one place).

It doesn't matter much if json-available-p is implemented in Lisp or C; even performance-wise it's a wash.





This bug report was last modified 2 years and 202 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.