From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Ihor Radchenko Newsgroups: gmane.emacs.devel Subject: Re: Why shouldn't we have a #if .... #else .... #endif construct in Emacs Lisp? Date: Sun, 10 Sep 2023 08:36:15 +0000 Message-ID: <87jzsypgqo.fsf@localhost> References: <87cyyr7i2i.fsf@localhost> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="9127"; mail-complaints-to="usenet@ciao.gmane.io" Cc: acm@muc.de, ulm@gentoo.org, emacs-devel@gnu.org To: rms@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Sep 10 10:36:10 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 1qfFvO-00026l-Kk for ged-emacs-devel@m.gmane-mx.org; Sun, 10 Sep 2023 10:36:10 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qfFul-00014A-9k; Sun, 10 Sep 2023 04:35:31 -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 1qfFui-000107-Jj for emacs-devel@gnu.org; Sun, 10 Sep 2023 04:35:28 -0400 Original-Received: from mout02.posteo.de ([185.67.36.66]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qfFud-0006Ng-CH for emacs-devel@gnu.org; Sun, 10 Sep 2023 04:35:28 -0400 Original-Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id 4680B240101 for ; Sun, 10 Sep 2023 10:35:21 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1694334921; bh=lzzlqm7Yb3lPYuOUPUOsIjX6bCMEVopxFK6TSWVD+8U=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:From; b=WKMqphYa7g1vdzi6K5tn3JtOpShrBVTnVxonC0ZG/cqkrC4XWKIgQojk7txF/UY5n t7GxDEo+8a28CqKTmvPU+N4V3dt91DFMM9SR0Mz3fpBMQuHVpJXcdLJs+lE6kAa4W0 mdsvUVGPMhCeZEqj/lUq3Namluc3aZpUaMya5v1/SOoTSe+By4kOCvOaIaCZ6rFBAo KijTYkWnnOxLCZ6F6vIbop1jT3Lx51FC85T7XgNpfVZAfsSlet3hW6Kgb4fYm9HN9U 36NyEQs5GhHcnGNBUG12BxN8FM+5RIkTjmI8K8eoGXPdCzXiUPYhZ0iYuGZuS+xP+4 op9TmnD9QwyiA== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4Rk37r2qm9z9rxG; Sun, 10 Sep 2023 10:35:20 +0200 (CEST) In-Reply-To: Received-SPF: pass client-ip=185.67.36.66; envelope-from=yantar92@posteo.net; helo=mout02.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable 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:310440 Archived-At: Richard Stallman writes: > > Because there are cases when `fboundp' should be checked at runtime. > > For example, some parts of Org use `fboundp' to check if certain > > third-party optional dependencies are loaded. If `fboundp' is resolved > > at compile time, such checks will be broken. > > I am confident there is a convenient way to distinguish the cases > where you want run-time tests from those where you would like > compile-time tests. But I can't try to look for it until I see > what the former cases look like. Can you show me an example? Org mode uses `fboundp' check to fontify arbitrary source blocks: #+begin_src language ... #+end_src The corresponding code does the following: (defun org-src-font-lock-fontify-block (lang start end) "Fontify code block between START and END using LANG's syntax. This function is called by Emacs' automatic fontification, as long as `org-src-fontify-natively' is non-nil." ... (let ((lang-mode (org-src-get-lang-mode lang))) (when (fboundp lang-mode) This cannot be optimized on compile time because we cannot know in advance which languages are to be fontified by user. Another example is Org mode optional inlinetask library "org-inlinetask". When the library is loaded, certain constructs are parsed differently in Org files: (defun org-back-to-heading (&optional invisible-ok) "Go back to beginning of heading or inlinetask." (forward-line 0) (or (and (org-at-heading-p (not invisible-ok)) (not (and (featurep 'org-inlinetask) (fboundp 'org-inlinetask-end-p) ; <---- (org-inlinetask-end-p)))) This must also be a runtime check, because it is up to the users whether this optional library is to be used or not. -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at