From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.devel Subject: Re: Should `indirect-function' be preferred over `fboundp'? Date: Thu, 20 Jul 2023 13:02:34 +0000 Message-ID: References: <87h6pzxdof.fsf@localhost> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="37237"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Ihor Radchenko Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Jul 20 15:04:06 2023 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qMTKA-0009Ms-Rm for ged-emacs-devel@m.gmane-mx.org; Thu, 20 Jul 2023 15:04:06 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qMTJA-0004qY-Lh; Thu, 20 Jul 2023 09:03:04 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qMTIz-0004hf-9z for emacs-devel@gnu.org; Thu, 20 Jul 2023 09:02:55 -0400 Original-Received: from mx3.muc.de ([193.149.48.5]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qMTIk-0005cl-ST for emacs-devel@gnu.org; Thu, 20 Jul 2023 09:02:51 -0400 Original-Received: (qmail 40835 invoked by uid 3782); 20 Jul 2023 15:02:35 +0200 Original-Received: from acm.muc.de (p4fe15497.dip0.t-ipconnect.de [79.225.84.151]) (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP; Thu, 20 Jul 2023 15:02:35 +0200 Original-Received: (qmail 7076 invoked by uid 1000); 20 Jul 2023 13:02:34 -0000 Content-Disposition: inline In-Reply-To: <87h6pzxdof.fsf@localhost> X-Submission-Agent: TMDA/1.3.x (Ph3nix) X-Primary-Address: acm@muc.de Received-SPF: pass client-ip=193.149.48.5; envelope-from=acm@muc.de; helo=mx3.muc.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:307987 Archived-At: Hello, Ihor. On Thu, Jul 20, 2023 at 07:08:48 +0000, Ihor Radchenko wrote: > 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 I don't think it affects the point you are making, but why are you using funcall in the last line, rather than just calling the funcion as (yant/foo) ? I initially got confused and thought you were doing (funcall yant/foo) , which would have been an obvious error. > 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 . > Support Org development at , > or support my work at -- Alan Mackenzie (Nuremberg, Germany).