emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Should `indirect-function' be preferred over `fboundp'?


From: Ihor Radchenko
Subject: Should `indirect-function' be preferred over `fboundp'?
Date: Thu, 20 Jul 2023 07:08:48 +0000

Hi,

I have recently stumbled upon the common Elisp pattern
(when (fboundp func) (funcall func)) failing.

This is happening when a symbol is declared as function alias to
non-existing function:

(defalias 'yant/foo 'yant/bar)
(fboundp 'yant/foo) ; => t
(funcall 'yant/foo) ; => ERROR: Symbol function definition is void: yant/foo

In contrast, `indirect-function' does a better job determining whether a
given symbol can be called as a function:

(indirect-function 'yant/foo) ; => nil

Is it something widely known?
Is it something to worry about?
(I can see that `fboundp' is used all over Emacs git sources, while
`indirect-function' is rarely used)

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]