From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: Why shouldn't we have a #if .... #else .... #endif construct in Emacs Lisp? Date: Sat, 02 Sep 2023 18:17:51 +0300 Message-ID: <834jkca9k0.fsf@gnu.org> References: Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="32681"; mail-complaints-to="usenet@ciao.gmane.io" Cc: stefankangas@gmail.com, emacs-devel@gnu.org, mattiase@acm.org To: Alan Mackenzie Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Sep 02 17:18:55 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 1qcSOk-0008CI-Nv for ged-emacs-devel@m.gmane-mx.org; Sat, 02 Sep 2023 17:18:54 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qcSO0-0000gz-1d; Sat, 02 Sep 2023 11:18:08 -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 1qcSNy-0000gZ-5M for emacs-devel@gnu.org; Sat, 02 Sep 2023 11:18:06 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qcSNw-0007xU-SS; Sat, 02 Sep 2023 11:18:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=N2WNAdIixGwzZEreK/6losgggDK50UwKAcjnOXwotKU=; b=am5uODrLClgrHqLAdBIZ cHvSspMSEQsSqNvMrjBn9mXyqJ3/Xm5mrWaN9fZbazwBk43ddNbwHDnf7Q3SWbGe50RqYd7XQwp30 cS72f7NjZdN0m+ZRCpOeOx9cEeOwLn2x8sC6NWXQgStA59lDyGWwBxJIny/f5I0OZz9bbNQpe3L/w /pA+wuqWgu+goQ58Dh6+pVzIXeQImetFz6EROcH+RN/lPSXMor2TP6f8r/PrFOvH3KcUi+210O3oZ iC/VoQFlh/GOX7BgUZe97jkc1K4MOjb7+zTlPCtTfUl+SkPnVUS6BzTJMlLz3ax6ig4Fm+FnfxAm7 RFeboqW0YgJvfg==; In-Reply-To: (message from Alan Mackenzie on Sat, 2 Sep 2023 15:06:46 +0000) 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:309896 Archived-At: > Date: Sat, 2 Sep 2023 15:06:46 +0000 > Cc: emacs-devel@gnu.org, > Mattias Engdegård > From: Alan Mackenzie > > +@node Conditional Compilation > +@section Conditional Compilation > + > + There will be times when you want certain code to be compiled only > +when a certain condition holds. This is particularly the case when > +maintaining Emacs packages; to keep the package compatible with older > +versions of Emacs you may need to use a function or variable which has > +become obsolete in the current version of Emacs. > + > + You could just use a conditional form to select the old or new form > +at run time, but this tends to output annoying warning messages about > +the obsolete function/variable. For such situations, the macro > +@code{static-if} comes in handy. It is inspired by the conditional > +compilation directives like @code{#if} in C like languages, and is > +patterned after the special form @code{if} (@pxref{Conditionals}). > + > + To use this facility for an older version of Emacs, copy the source > +for @code{static-if} from the Emacs source file @file{lisp/subr.el} > +into your package. Thanks, but I think the references to #if make the documentation less helpful than it could be. This manual is for Lisp programmers, and those are not necessarily familiar with C and its preprocessor directives. So I think it would be better if you removed the references to cpp. If you think removing that would make the documentation less self-explanatory, I suggest to add explanations that are based on Lisp and on typical situations while writing Lisp programs, not on cpp. > --- a/etc/NEWS > +++ b/etc/NEWS > @@ -855,6 +855,10 @@ Use 'define-minor-mode' and 'define-globalized-minor-mode' instead. > See the "(elisp) Porting Old Advice" node for help converting them > to use 'advice-add' or 'define-advice' instead. > > ++++ > +** There is now conditional compilation, based on the C language's #if. > +To use this, see the new macro 'static-if'. Same here. Here, it is actually worse: "based on C language's #if" could be misinterpreted as meaning the implementation is based on #if in some way. I would suggest the following text in NEWS: ** New macro 'static-if' for conditional byte-compilation of code. This macro hides a form from the byte-compiler based on a compile-time condition. This is handy for avoiding byte-compilation warnings about code that will never actually run under some conditions. Thanks.