|
From: | Philip Kaludercic |
Subject: | Re: Why shouldn't we have a #if .... #else .... #endif construct in Emacs Lisp? |
Date: | Sat, 02 Sep 2023 19:20:29 +0000 |
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? > +(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)))
[Prev in Thread] | Current Thread | [Next in Thread] |