m4-discuss
[Top][All Lists]
Advanced

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

Re: POSIX vs. eval


From: Eric Blake
Subject: Re: POSIX vs. eval
Date: Wed, 03 Jan 2007 07:31:53 -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 Gary V. Vaughan on 12/29/2006 1:27 PM:
> Hi Eric,

Hi Gary, and happy new year,

> 
> On 28 Dec 2006, at 14:41, Eric Blake wrote:
>> The current wording of the m4 eval macro forbids implementations from
>> providing the , and  ?: operators as extensions, even though these
>> operators could reasonably be implemented (all of the other forbidden
>> operators involve C language constructs that are not available with
>> strict numerical evaluations).  The BSD implementation of M4 already
>> provides ?:.
> 
> Agreed.  As long as extensions are labeled as such for each
> implementation, the onus is on the user to decide whether to
> use the extension and lock their code in, or ignore the extensions
> in exchange for having portable code.
> 
> I think the only change in the POSIX wording would be to remove
> the forbid aspect, and instead list all the required operators.

Here's the aardvark I finally submitted:
https://www.opengroup.org/sophocles/show_mail.tpl?CALLER=index.tpl&source=L&listname=austin-review-l&id=2250

In preparing the aardvark, I also realized that it may be worth adding the
following GNU extension in m4 2.0.  Currently, if eval encounters a word
(ie. macro name), it is a syntax error.  But we could check if the
definition of that macro is a number, and thus support variables; once
variables are supported, we can then also support assignment operators.
Thus "define(a,1)ifelse(eval(`a++'))a" would expand to "2", similar to the
shell construct "a=1; : $((a++)); echo $a".

- --
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

iD8DBQFFm75Z84KuGfSFAYARAj4+AJ4h8ndRMerkffd0/cdcnroeEHrYBQCfV2hf
GOrvHbJYw44jr6LVlXp1Enw=
=m0cD
-----END PGP SIGNATURE-----




reply via email to

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