Subject: Re: bug#24245: closed (Re: bug#24245: 25.0.93; AUCTeX TeX-function-p)

From: [email-masked]
Date: Thu, 01 Sep 2016 22:40:44 -0400

From: Mosè Giordano <[email-masked]>
>Hi
>
>2016-08-19 18:42 GMT+02:00 Robert Cochran <[email-masked]>:
>> <[email-masked]> writes:
>>
>>> What is the actual purpose of the Lisp function `TeX-function-p' found
>>> in AUCTeX ‘tex.el’?
>>>
>>> (defun TeX-function-p (arg)
>>>   "Return non-nil if ARG is callable as a function."
>>>   (or (and (fboundp 'byte-code-function-p)
>>>        (byte-code-function-p arg))
>>>       (and (listp arg)
>>>        (eq (car arg) 'lambda))
>>>       (and (symbolp arg)
>>>          (fboundp arg))))
>>>
>>> How this code is better of `functionp'?
>>> If there is no actual design improvement of `TeX-function-p' over
>>> `functionp', the latter is supposed to be faster as it is built-in.

It's possibly worse, since `TeX-function-p' will misidentify closures as
non-functions.

>>
>> It's not 'better'. A blame of the AUCTeX repository shows that
>> `TeX-function-p` was written (and last touched) in 1994. The only
>> history that's in the Emacs repository commit-wise about `functionp`
>> dates back to 2010, and the files within it show relevant history from
>> 2005 (which aren't in the repo as their own commits). Doubtless it's
>> hard to pin down without the complete history, but it's likely
>> `TeX-function-p` was written before `functionp`.
>
>`functionp' seems to have been introduced in Emacs with commit:
>
>    * a9a44ed (1997-04-12)  (functionp): New function.
>
>so well before GNU Emacs 21.1, that is the oldest version of Emacs we
>aim to support.  I agree `functionp' should be able to safely replace
>`TeX-function-p', I tested with Emacs 22, 23, and 24.

It might cause problems in Emacs 22, I find this in NEWS.23:

    * Incompatible Lisp Changes in Emacs 23.1
    [...]
    ** `functionp' returns nil for special forms.
    I.e., it only returns t for objects that can be passed to `funcall'.

>From which I gather that before then, `functionp' would return t for
special forms.