autoconf-patches
[Top][All Lists]
Advanced

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

Re: M4 syntax $11 vs. ${11}


From: Eric Blake
Subject: Re: M4 syntax $11 vs. ${11}
Date: Tue, 30 Jan 2007 06:04:51 -0700
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.9) Gecko/20061207 Thunderbird/1.5.0.9 Mnenhy/0.7.4.666

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to Ralf Wildenhues on 1/29/2007 11:44 AM:
> Hello Eric, all,

Hello in return,

>>      * doc/autoconf.texi (Quoting and Parameters): New section.
> 
> This makes things inconsistent.  Quoting `Coding Style':
> 
> | Otherwise, the closing bracket would be hidden inside a `#'-comment,
> | breaking the bracket-matching highlighting from Emacsen.  Note the
> | preferred style to escape from M4: `$[1]', address@hidden', etc.  Do not 
> escape
> | when it is unnecessary.  Common examples of useless quotation are
> | `[$]$1' (write `$$1'), `[$]var' (use `$var'), etc.  If you add
> | portability issues to the picture, you'll prefer `${1+"address@hidden"}' to
> | `"[$]@"', and you'll prefer do something better than hacking Autoconf
> | `:-)'.

I didn't notice this later section when I went to the effort in my new
'Quoting and Parameters' to document that $ and 1 must be separated by
nested quotes.

> 
> The Coding Style ends up being inconsistent with
>   $[#]                  where it's necessary to quote the hash,

You missed the earlier line that recommended address@hidden:@] instead of $[#] 
for
the sake of syntax highlighting, even though both have the same effect.

>   $[1]                  where either character could be quoted,
>   [$]{1...}  vs.  $[{1...}]  vs.  $[{]1...}
>                         where the first is inconsistent with the
>                         previous examples, and the others are ugly,

What about a slightly different approach:

When in a single-quoted context, use an empty quote to separate the $ from
the next character:
AC_FOO([ address@hidden:@ ])    to avoid $# as well as comment, use a 
quadrigraph
AC_FOO([ $[]1 ])       instead of $1
AC_FOO([ $[]{1...} ])  instead of ${1...}

and when in a double-quoted context (less common, since we recommend one
level of quotes per parentheses), use an inverted empty quote to break the
string into two parts:
AC_FOO([[ $][# ]])   no quadrigraph necessary
AC_FOO([[ $][1 ]])
AC_FOO([[ $][{1...} ]])

> 
> and is not applied throughout the manual (see the `${1+"address@hidden"}' at 
> the
> end of the quoted paragraph).

Which would turn the last example into $[]{1+"$[]@"}.

> 
> IMHO, it's not a good idea to not "practice what we preach" in any
> direction: either have the code be more cautious than the documentation,
> or vice versa.

Unfortunately, I think existing code in autoconf alone is full of several
styles.  Would it be worth my time to also prepare a mechanical patch that
tries to convert existing uses into a single style?

Or maybe we just give up, and flat out document that as long as autoconf
supports both M4 1.4.x and 2.0 simultaneously, m4's --warn-syntax option
must not be used.  Then only the line in m4sugar that uses changesyntax to
cripple M4 2.0's ${1} parsing is needed, and we can ignore false
positives.  More thoughts along that front in response to Paul.

> 
> (But maybe you have arrived at another iteration of the patch already,
> obsoleting my comments; I haven't seen any newer patch, though.)

So far, the patch from the 27th is the most recent.

- --
Don't work too hard, make some time for fun as well!

Eric Blake             address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFFv0Jy84KuGfSFAYARAuSLAKCMieAmfwILT24W4jnaksC+0fyPYgCg1HLH
Y2dPKo0ZwNT8tGHVhoM7G+k=
=MayT
-----END PGP SIGNATURE-----




reply via email to

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