autoconf
[Top][All Lists]
Advanced

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

Re: comma separated lists


From: Bruno Haible
Subject: Re: comma separated lists
Date: Mon, 17 Feb 2003 22:39:28 +0100 (CET)

Peter Eisentraut wrote:
> The difference between space-separated lists and comma-separated lists is
> approximately like writing in C func("arg1 arg2 arg3") rather than
> func(arg1, arg2, arg3).  It is not "proper" for the language being used.
> It is a historical mistake that is being phased out.

This argument is bogus in two ways:

  1) autoconf is not C. autoconf's input is processed through *m4*, and
     results in *sh* output. Some autoconf macros contain C code, just like
     some other macros contain Fortran snippets, but the best proof that C
     is not central in autoconf is that the  [ ]  tokens stand for something
     different in autoconf input than in C.

  2) autoconf knows about two kinds of lists (see *Node: Input processing):
     - Argument lists of m4 functions, where each argument has a different
       meaning (because most m4 functions are not variadic).
     - Token lists, where each token has the same meaning.

     C doesn't even have the second concept. By using commas for AC_CHECK_DECLS
     arguments you mix up two concepts, because you extrapolate from limited
     programming languages to richer ones.

> The new style will
> make the system more robust, which is not immediately visible to user, of
> course, but ultimately for his benefit.

Comma as separators always make the empty list a special case (because it has
0 commas, like the list with 1 element). Their use makes any programming
languages *less* robust. Don't you remember the problem with the semicolons
in the PASCAL language, where semicolons were statement separators, not
statement terminators?

> > Whereas the second disadvantage of comma-separated lists is that it
> > doesn't support computing the list at configure time:
> >
> > funcs="malloc, free, foobar"
> > AC_CHECK_DECLS([$funcs])
> >
> > funcs="getenv foobar"
> > AC_CHECK_DECLS([$funcs])
> >
> > Doesn't work!
> 
> This approach is already dysfunctional right now, because if you write it
> that way it's not traceable and autoheader and other tools that depend on
> tracing, such as automake, will screw up.

Of course I called AH_TEMPLATE myself at the point where I generate the
'funcs' assignment. Your argument is therefore moot.

> There is an easy fix.  You can write
> 
> if condition1; then
> AC_CHECK_DECLS(getenv)
> fi
> 
> if condition2; then
> AC_CHECK_DECLS(foobar)
> fi

This style leads to the 800 KB configure files that we have now and that bloat
every GNU distribution.

Bruno




reply via email to

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