m4-discuss
[Top][All Lists]
Advanced

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

Re: Tips for features


From: Akim Demaille
Subject: Re: Tips for features
Date: 04 Oct 2001 10:39:55 +0200
User-agent: Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.4 (Artificial Intelligence)

| > * macro: set maximum level of inclusion
| 
| For loop detection?

  -L, --nesting-limit=NUMBER   change artificial nesting limit

(very useful BTW).


| > * macro: set parameter evaluation: yes/no
| > * macro: set type of param eval: before/after parsing
| 
| I see what you are getting at, but I am finding it hard to imagine an
| example where having these features is a win over what we have
| already.  It is "just" a matter of quoting carefully arfter all.

Yes, yes, yes.  Don't change the semantics.  If you really want to do
something to ease M4 programming, then, IMHO, what we need is
something like `eval' (too bad the name is already used, grrrr), or
`expand':

        expand([something])

which run `something', and return its result quoted.  But be afraid,
be very afraid of the semantics (what if there are `define' in there
etc.).


| > * macro: date/time through strftime
| 
| We already have this in one of the test modules in CVS IIRC.

Correct.

| > * macro: read/write environment
| 
| Reading is implemented by converting the environment into text macros.
| Why would writing the environment be useful?

Anyway: 

src/m4/modules % grep 'BUILTIN ' stdlib.c                        nostromo 10:35
        BUILTIN (getcwd,        FALSE,  FALSE)  \
        BUILTIN (getenv,        FALSE,  TRUE)   \
        BUILTIN (getlogin,      FALSE,  FALSE)  \
        BUILTIN (getpid,        FALSE,  FALSE)  \
        BUILTIN (getppid,       FALSE,  FALSE)  \
        BUILTIN (getuid,        FALSE,  FALSE)  \
        BUILTIN (getpwnam,      FALSE,  TRUE)   \
        BUILTIN (getpwuid,      FALSE,  TRUE)   \
        BUILTIN (hostname,      FALSE,  FALSE)  \
        BUILTIN (rand,          FALSE,  FALSE)  \
        BUILTIN (srand,         FALSE,  FALSE)  \
===>    BUILTIN (setenv,        FALSE,  TRUE)   \
        BUILTIN (unsetenv,      FALSE,  TRUE)   \
        BUILTIN (uname,         FALSE,  FALSE)



| > * macro: eval - implicit multiplication before `(', variable, unary +/-,
| >          not necessary to write right closing `)' (if well quoted)
| 
| Ai-ya!  Are you sure?  Unary +/- should be easy.

It certainly is:

src/m4/modules % m4                                              nostromo 10:35
eval(+1)
1
eval(1++2)
3

As for the rest, I am strongly opposed to it.  Sloppy syntax is the
beginning of many problems.  Have a look at an HTML parser, and pray.


| > * macro: label/goto to simplify loops
| 
| That would be tough.  And it seems to go against the way everything
| else works, so I wouldn't be keen on this.

M4 has a strong functional flavor.  Let's keep it clean.


| > * macro: split string by given delimiter and return nth field (internal
| >          implementation of array)
| 
| That would be cool.  Easy to do as a module too.

As far as arrays are concerned, you can

define([array(len)], 2)
define([array[0]], 42)
define([array[1]], 51)



reply via email to

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