emacs-devel
[Top][All Lists]
Advanced

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

Re: Why shouldn't we have a #if .... #else .... #endif construct in Emac


From: Alan Mackenzie
Subject: Re: Why shouldn't we have a #if .... #else .... #endif construct in Emacs Lisp?
Date: Sat, 2 Sep 2023 19:58:01 +0000

Hello, Philip.

On Sat, Sep 02, 2023 at 19:20:29 +0000, Philip Kaludercic wrote:
> Alan Mackenzie <acm@muc.de> 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).



reply via email to

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