bug-m4
[Top][All Lists]
Advanced

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

Re: enhancement suggestions


From: Gary V. Vaughan
Subject: Re: enhancement suggestions
Date: Fri, 11 Feb 2005 15:04:50 +0000
User-agent: Mozilla Thunderbird 0.9 (X11/20041103)

Stepan Kasal wrote:
> Hi Akim and Gary,

Hallo!

> On Thu, Feb 10, 2005 at 01:55:16PM +0100, Akim Demaille wrote:
> 
>>>>>"Stepan" == Stepan Kasal <address@hidden> writes:
>>
>> > +  + We need a way to ask for one level of expansion; this is somewhat
>> > +    similar, but not identical, to `defn'.  For example:
>> > +       expandonce(`macro(a, b, c)')
> 
> 
>>I'm not sure I agree with the "once".  You just apply the regular
>>evaluation rules, and return the result quoted.  But if foo is defined
>>to bar, and bar to baz, then eval([foo]) should definitely return [baz].
> 
> 
> I believe this can be implemented as
> 
>       define([m4_quote], [[$1]])
> 
> the parameter is fully evaluated and then quoted.  Unless the expansion
> contains an unmatched quote, everything works.

There is an outstanding issue of how to handle hard quotes, which should
allow for unbalanced quotes in cases like this.  I haven't thought to hard
about it, except to notice that it is a problem.  What is needed is some
way to mark non-matching quotes internally.  Input on how to design this
feature would be most welcome :-)

> What we need is exactly the ``once'' feature.
> 
> After an irc discussion with Gary, his proposal has landed as `qindir' to
> the TODO file in the CVS head.  Let me cite it:
> 
>   + Implement qindir.  Like indir, except that the result of the macro call
>     is not expanded.  Because the input stack might contain a file or a
>     string, it is probably best achieved by making note that the TOS input
>     should be copied rather than rescanned.
> 
>       $ echo "a'b" > f
>       $ m4
>       define(a,z)dnl
>       include(f)dnl
>       z'b
>       indir(`include', f)dnl
>       z'b
>       qindir(`include', f)dnl
>       a'b
>       define(b,NONO)dnl
>       patsubst(qindir(`include', f), b, x)
>       z'x

Did you mean to add a quote there:
        patsubst(qindir(`include', f), `b', x)

Or are you trying to specify a different use case:
        qindir(`patsubst', qindir(`include', f), `b', x)

I'm not sure I understand what the NONO is trying to illustrate :-(

> On Thu, Feb 10, 2005 at 03:54:45PM +0000, Gary V. Vaughan wrote:
> 
>>Akim Demaille wrote:
>>
>>>Rather I think we should have another set of builtins.
>>
>>As in qregexp, qinclude, qifelse and so on?  [...]
>  
> I think Akim was not aware about the qindir proposal when he wrote this.

Certainly, but I want to see if Akim can see a problem with it that we
have missed...

>>>While you're at it, the new regexp
>>>builtins should drop BRE dead, and use ERE too.
> 
> Well, as it doesn't look as if we were adding an alternate set of builtins,
> I believe we could take this as a proposal to implement `eregexp' and
> `epatsubst'.

1.4 has BRE patsubst and regexp, and CVS additionally has epatsubst and
eregexp.

I don't see how switching patsubst and regexp over to ERE won't cause
problems for legacy code though :-(  Wouldn't old versions of m4sugar.m4
start failing mysteriously if they were run with an M4-2.0 that uses
ERE in patsubst and regexp?

Cheers,
        Gary.
-- 
Gary V. Vaughan      ())_.  address@hidden,gnu.org}
Research Scientist   ( '/   http://tkd.kicks-ass.net
GNU Hacker           / )=   http://www.gnu.org/software/libtool
Technical Author   `(_~)_   http://sources.redhat.com/autobook

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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