bug-autoconf
[Top][All Lists]
Advanced

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

Re: Warnings for excessive macro arguments


From: Eric Blake
Subject: Re: Warnings for excessive macro arguments
Date: Mon, 23 Aug 2010 15:59:04 -0600
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.8) Gecko/20100806 Fedora/3.1.2-1.fc13 Mnenhy/0.8.3 Thunderbird/3.1.2

On 08/23/2010 03:45 PM, Ralf Wildenhues wrote:
* Yavor Doganov wrote on Mon, Aug 23, 2010 at 09:42:54PM CEST:
Eric Blake wrote:
I have to wonder if there are cases where rejecting extra arguments
might not be advisable,

No, the behavior should remain the same (silently ignoring them); any
change smells like a dangerous path to follow.  The only difference
would be the warnings (well, errors with -Werror, unfortunately).

The problem with this approach is that we then cannot ever extend a
macro by adding new detected arguments, without also breaking backward
compatibility that way.  That means, each feature addition requiring
more arguments would now also require a new macro name, wasting more
good names in the process.  :-/

Requiring a minimum number of arguments is problematic - existing code cannot be compiled with a newer autoconf that requires a larger minimum. That is, we intentionally document that AC_RUN_IFELSE([arg1]) and AC_RUN_IFELSE([arg1], [], [], []) are identical, therefore AC_RUN_IFELSE must not print a warning if $# is less than 4. Or, in m4 terms, we prefer that choices be made on whether $4 is the empty string, and not on whether $# == 4; when $4 is a documented argument. The m4 builtin regexp is an example where regexp([abc],[b]) behaves much differently than regexp([abc],[b],[]), because it specifically checks $#, but that's confusing enough that you can see why we don't encourage those semantics in other autoconf macros.

Meanwhile, I don't see how warning on unexpected arguments is a problem - code that wants to be portable to both old and new autoconf will only use as many arguments as the old version supported. On the upgrade path, if 2.67 supports only ABC(arg1), but 2.68 supports ABC(arg1, arg2), then calling ABC(arg1, oops) in 2.67 would be a syntax warning, while in 2.68 it would silently assume you wanted to use the new argument feature. But it does imply that to get the full benefit of those portability warnings that you would have to use the oldest version of autoconf that you plan to be portable to (but also one new enough that it actually detects and prints warnings in the first place).

--
Eric Blake   address@hidden    +1-801-349-2682
Libvirt virtualization library http://libvirt.org



reply via email to

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