Subject: Re: bug#56648: 29.0.50; Need for `compiled-function-p`

From: Stefan Monnier <[email-masked]>
Date: Sun, 14 Aug 2022 22:36:04 -0400

>> >> -  (or (byte-code-function-p (symbol-function 'byte-compile-form))
>> >> -      (subr-native-elisp-p (symbol-function 'byte-compile-form))
>> >> -      (assq 'byte-code (symbol-function 'byte-compile-form)) <<<<<<<<<<<<<
>> >> +  (or (compiled-function-p (symbol-function 'byte-compile-form))
>> 
>> According to my reading of the code, this `assq` can never return
>> non-nil.
>
> Too bad the commit log message didn't say that, then.  Imagine someone
> 5 or 10 years from now trying to understand the fine points of that
> changeset...

If (assq 'byte-code (symbol-function 'byte-compile-form)) returns
non-nil, it means that the `byte-compile-form` function has been
byte-compiled by the Emacs-18 byte-compiler (the byte-code-function type
was only introduced in Emacs-19).

So `compiled-function-p` *should* replace all 3 cases.

IOW I believe the above diff is "obviously right" and the question is
whether `compiled-function-p` should be changed to return non-nil for
functions of the form (lambda (...) (byte-code ...)), i.e. those
functions generated by Emacs-18's byte-compiler.  I hope we don't need
to keep that backward compatibility, tho ;-)

        Stefan