m4-patches
[Top][All Lists]
Advanced

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

Re: FYI: 5-gary-macro-formal-parameter-first-cut.patch


From: Akim Demaille
Subject: Re: FYI: 5-gary-macro-formal-parameter-first-cut.patch
Date: Thu, 12 Jun 2003 09:15:46 +0200
User-agent: Gnus/5.1002 (Gnus v5.10.2) Emacs/21.3 (gnu/linux)

 >> Just applied to HEAD.
 >> Most of this is okay, and it certainly works.  But it strikes me that
 >> it would be much more elegant to pushdef the values named by the
 >> formal parameter list for the duration of the expansion of a macro.
 >> In the body of a macro the parameters would be referenced by name
 >> (without a leading $) and there would be dynamic scoping since nested
 >> macros could reference parameters from their parents.

 >> define(`foo(bar)', `blah: bar')
 >> foo(`baz')
 >> =>blah: baz
 >> define(`quux(blah)', `quux: blah; foo(`argh')')
 >> quux(`baz')
 >> =>quux: baz; baz: argh

 >> Comments?

 > I hate dynamic scoping :(  But it's already the rule here, so...

 > Nice idea, but I need more time to think about this.

Not a good idea.  $1 etc. have a completely different behavior, of
course.

Consider:

        define([foo], [[[$1]]])
        foo([bar])

That would never work with pushdef.  That's also why I'd like to
encourage a $ mark for the arguments, they are special beasts.

And actually, I also think addressing this issue should be done
simultaneously with prototyping, i.e., m4 should complain when there
is not the right number of arguments etc.

But then we need to support multi-prototypes macros.  Maybe we should
have a look at Perl?

     define([foo($a, $b; $c, $d; $e)], ...

Would support 2, 4 or 5 arguments.  Hm.  How about 0?  And how about
n-ary macros?

There is plenty of things to think about.  A module aware M4 is truly
needed though...




reply via email to

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