[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: |
LdBeth |
Subject: |
Re: Why shouldn't we have a #if .... #else .... #endif construct in Emacs Lisp? |
Date: |
Tue, 29 Aug 2023 11:28:04 -0500 |
User-agent: |
Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (Gojō) APEL-LB/10.8 EasyPG/1.0.0 Emacs/29.1 (x86_64-apple-darwin20.6.0) MULE/6.0 (HANACHIRUSATO) |
>>>>> In <ZOz3lR_4Al88SEJ_@ACM>
>>>>> Alan Mackenzie <acm@muc.de> wrote:
acm> Hello, Emacs.
acm> In Emacs Lisp we have no such construct. This is a Bad Thing.
acm> More and more, especially recently, irritating warning messages are
acm> occurring for, for example, obsolete variables and functions inside
acm> conditionals which ensure they aren't used. For example:
acm> (when (< emacs-major-version 24)
acm> (defadvice .....))
acm> produces the warning about defadvice being obsolete. (I haven't actually
acm> tested this example). What we really want here is for the defadvice only
acm> to be _compiled_ when (< emacs-major-version 24), rather than compiled
acm> unconditionally and not run.
acm> I propose a new function, hash-if, which would do what we want. The
acm> above example could then be written something like:
acm> (hash-if (< emacs-major-version 24)
acm> (defadvice .....)
acm> (advice-add .....))
Have a look at `static.el' from APEL
https://github.com/wanderlust/apel
It provides `static-if' and other useful macros.
(defmacro static-if (cond then &rest else)
"Like `if', but evaluate COND at compile time."
(if (eval cond)
then
`(progn ,@ else)))
- 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/08/29
Re: Why shouldn't we have a #if .... #else .... #endif construct in Emacs Lisp?, Stefan Kangas, 2023/08/29
Re: Why shouldn't we have a #if .... #else .... #endif construct in Emacs Lisp?,
LdBeth <=