Boost logo

Boost :

From: Karl Nelson (kenelson_at_[hidden])
Date: 2002-02-22 17:02:26

> > > And nearly anything would be better then m4.
> >
> > "Nearly anything" won't necessarily accomplish what m4 accomplishes.
> > What would be some viable alternatives?
> Huh? m4 is just a scripting language that does macro expansion.
> Perl could have been used instead (and actually was considered). Or
> python. Heck, even Java would work for this even though Java isn't a
> scripting language.

What is wrong with m4? I have in the past attempted to replicate
what m4 does with perl and others and other languages really aren't
as elegant as they seem. You end up constantly switching from the
output stream to the programming language.

Ie. What is fairly clear in m4

  // proxy to bar
  template <LOOP(class T%1,$2)>
  $1 foo_function(LOOP(T%1 t%1))
      ifelse($1,void,,return ) bar(LOOP(t%1));

becomes something totally unreadable in perl

  sub expand_FOO
    print "// proxy to bar\n";
    print "template <";
    for ($i=1;i<=$args;$i++)
      { print "class T$i t$i" };
    print ">\n";
    print "$return_type foo_function(";
    for ($i=1;i<=$args;$i++)
      { print "T$i t$i" };
    print ")\n";
    print " {\n";
    print " "; print "return" if ($return_type!="void");
    print "bar(";
    for ($i=1;i<=$args;$i++)
      { print "t$i" };
    print ");\n";
    print "}\n";

becomes something totally unreadable in perl. Of course
this is because auto* tools are making shell scripts rather
the directly making scripts so this argument doesn't cleanly
apply to a different system.

Further, m4 is not a scripting language. It is a macro expansion
tool and a more fair comparision would be m4 to cpp. On that
account m4 wins hands down. Maybe better comparision would be php.

  (One of the few people on Earth who like m4)

Boost list run by bdawes at, gregod at, cpdaniel at, john at