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: Ulrich Mueller
Subject: Re: Why shouldn't we have a #if .... #else .... #endif construct in Emacs Lisp?
Date: Mon, 28 Aug 2023 21:47:57 +0200
User-agent: Gnus/5.13 (Gnus v5.13)

>>>>> On Mon, 28 Aug 2023, Alan Mackenzie wrote:

> In C, we have the very useful conditional compilation directives
> introduced by #if or #ifdef, etc., which end at #end.

> In Emacs Lisp we have no such construct.  This is a Bad Thing.

> More and more, especially recently, irritating warning messages are
> occurring for, for example, obsolete variables and functions inside
> conditionals which ensure they aren't used.  For example:

>     (when (< emacs-major-version 24)
>       (defadvice .....))

> produces the warning about defadvice being obsolete.  (I haven't actually
> tested this example).  What we really want here is for the defadvice only
> to be _compiled_ when (< emacs-major-version 24), rather than compiled
> unconditionally and not run.

I believe (eval-when-compile (< emacs-major-version 24)) would work?

> I propose a new function, hash-if, which would do what we want.  The
> above example could then be written something like:

>     (hash-if (< emacs-major-version 24)
>         (defadvice .....)
>       (advice-add .....))

But the old Emacs version wouldn't have the function, so it couldn't be
used like this. What am I missing?



reply via email to

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