[Top][All Lists]

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

Re: Suggestion to add ifndef builtin macro

From: Eric Blake
Subject: Re: Suggestion to add ifndef builtin macro
Date: Thu, 15 May 2014 14:29:00 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0

On 05/15/2014 02:13 PM, Daniel Goldman wrote:
> Hi,
> I would like to suggest the small change to add an m4_ifndef builtin
> macro to some future version of m4.

Why? You can already write your own m4_ifndef macro that wraps the
builtin.  We intentionally want a minimal set of builtins, and leave the
bulk of the power in wrappers around the builtins.

m4_define(`m4_ifndef', `m4_ifdef(`$1', `$3', `$2')')

> Reason #1 I suggest adding m4_ifndef is for better communication, to
> make the language easier to express the logic. Perhaps a lot of m4 usage
> is obscure, but I don't consider that a virtue. I would argue that:
> m4_ifndef(`MACRO_1', `MACRO_1' NOT defined)
> is clearer than:
> m4_ifdef(`MACRO_1', , `MACRO_1' NOT defined)

Yes, and that's why the autoconf language has an m4_ifndef wrapper
alongside the m4_ifdef wrapper.  But that didn't require a new builtin.

> Reason #1 in favor of NOT adding is because m4_ifdef is adequate to do
> the logical operations. To my understanding the following two macros are
> 100% equivalent:
> m4_ifdef(`MACRO_1', `MACRO_1' defined, `MACRO_1' NOT defined)
> m4_ifndef(`MACRO_1', `MACRO_1' NOT defined, `MACRO_1' defined)

Yes, if you write your m4_ifndef wrapper as above.

> $ cat ifndef-02.m4
> m4_define(`m4_ifndef', `m4_ifdef(`$1', `$3', `$2')')

Yep, you already wrote the correct composite macro.

Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

reply via email to

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