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: Why shouldn't we have a #if .... #else .... #endif construct in Emacs Lisp? Date: Sat, 2 Sep 2023 19:58:01 +0000 Message-ID: References: <87pm30e60y.fsf@posteo.net> 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="33516"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Stefan Kangas , emacs-devel@gnu.org, Mattias =?iso-8859-1?Q?Engdeg=E5rd?= To: Philip Kaludercic Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Sep 02 21:58:39 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 1qcWlT-0008XM-9C for ged-emacs-devel@m.gmane-mx.org; Sat, 02 Sep 2023 21:58:39 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qcWl0-0006fW-BL; Sat, 02 Sep 2023 15:58:10 -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 1qcWky-0006c8-Fg for emacs-devel@gnu.org; Sat, 02 Sep 2023 15:58:08 -0400 Original-Received: from mail.muc.de ([193.149.48.3]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qcWkv-0001IZ-P0 for emacs-devel@gnu.org; Sat, 02 Sep 2023 15:58:08 -0400 Original-Received: (qmail 35269 invoked by uid 3782); 2 Sep 2023 21:58:03 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=muc.de; i=@muc.de; q=dns/txt; s=default; t=1693684683; h=date : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to : from : from; bh=8fCVs1weMcAFDOTrZNocVg+aZLLiE11k8ZFvWKMSllc=; b=ql9WMSBcCvzdwH7UkbnzG9hMYnkTI2fBHI3IPSQBdzIlWluHmahU8TagLa7kkKC4inkpk VOEvW2yG1sjjcEXZNskaM5lo8uiA803AZWxVtmTAfL9A34x1u9mCeNGXtPJKoUviRD2LwAE nDMTyxc99eYavdw5e8BP2BaDSdasc3ErNFiRMQh5wh7Hbmpb583rG0RR2uMN5I5I4oguVQC ndAmtF+L25GGY4KR1t6tSl6jbcdEkyR2o8r+gF1DErRJTBbTPX5s45GF4sq9HTwsgiBY64I IDD/P3dFn0kKQQuY2EYi+34MA8IWDFxd36k/4+cVc/Bik0ib1jQ53/nJAmhA== Original-Received: from acm.muc.de (p4fe15929.dip0.t-ipconnect.de [79.225.89.41]) (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP; Sat, 02 Sep 2023 21:58:01 +0200 Original-Received: (qmail 369 invoked by uid 1000); 2 Sep 2023 19:58:01 -0000 Content-Disposition: inline In-Reply-To: <87pm30e60y.fsf@posteo.net> X-Submission-Agent: TMDA/1.3.x (Ph3nix) X-Primary-Address: acm@muc.de Received-SPF: pass client-ip=193.149.48.3; envelope-from=acm@muc.de; helo=mail.muc.de X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 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:309910 Archived-At: Hello, Philip. On Sat, Sep 02, 2023 at 19:20:29 +0000, Philip Kaludercic wrote: > Alan Mackenzie writes: > > +;; Note: `static-if' handles the version of `eval' without the &optional > > +;; parameter LEXICAL so that it can be copied unchanged for use in older > > +;; Emacsen. > Is this really a concern for the version that would be added to Emacs > itself? The idea was that there would be just one version, and a package maintainer could copy the 13 lines to the beginning of her package inside something like (when (not (fboundp 'static-if)) ....), but otherwise unchanged. > > +(defmacro static-if (condition then-form &rest else-forms) > > + "A conditional compilation macro analogous to C's #if. > > +Evaluate CONDITION at macro-expansion time. If it is non-nil, > > +expand the macro to THEN-FORM. Otherwise expand it to ELSE-FORMS > > +enclosed in a `progn' form. ELSE-FORMS may be empty." > > + (declare (indent 2) > > + (debug (sexp sexp &rest sexp))) > > + (if (condition-case err > > + (eval condition lexical-binding) > > + ((wrong-number-of-arguments void-variable) (eval condition)) > > + ((debug error) (signal (car err) (cdr err)))) > > + then-form > > + (cons 'progn else-forms))) -- Alan Mackenzie (Nuremberg, Germany).