[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: |
Stefan Monnier |
Subject: |
Re: Why shouldn't we have a #if .... #else .... #endif construct in Emacs Lisp? |
Date: |
Sat, 02 Sep 2023 19:09:04 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) |
> --8<---------------cut here---------------start------------->8---
> (defmacro cif (test then &rest else)
> "Evaluate TEST during macro-expansion and return THEN or ELSE."
> (if (eval test t) then else))
> --8<---------------cut here---------------end--------------->8---
FWIW I've used such macros in packages under the name
`<PKG>--if-when-compile`.
Also, FWIW, I've used the following variant to let the
compile-time check be reconsidered at runtime:
(defmacro TeX--if-macro-fboundp (name then &rest else)
"..."
(declare (indent 2) (debug (symbolp form &rest form)))
(if (fboundp name) ;If macro exists at compile-time, just use
it.
then
`(if (fboundp ',name) ;Else, check if it exists at
run-time.
(eval ',then) ;If it does, then run the then code.
,@else)))
-- Stefan
- Re: Why shouldn't we have a #if .... #else .... #endif construct in Emacs Lisp?, (continued)
Re: Why shouldn't we have a #if .... #else .... #endif construct in Emacs Lisp?, Philip Kaludercic, 2023/09/02
Re: Why shouldn't we have a #if .... #else .... #endif construct in Emacs Lisp?,
Stefan Monnier <=
Re: Why shouldn't we have a #if .... #else .... #endif construct in Emacs Lisp?, Stefan Monnier, 2023/09/02
Re: Why shouldn't we have a #if .... #else .... #endif construct in Emacs Lisp?, Richard Stallman, 2023/09/03
Re: Why shouldn't we have a #if .... #else .... #endif construct in Emacs Lisp?, Richard Stallman, 2023/09/05