Preprocessing (Was: Re: Recording what we decided *not* to do, and why)

2000-08-05 Thread Johan Vromans

Russ Allbery [EMAIL PROTECTED] writes:

 However, cpp has the significant advantage that its active syntax is
 designed to be embedded in a programming language and are Perl comments.
 This is *not* true of m4, which would be horribly, horribly confused by a
 Perl script.

I fail to see this point.
Having a program depend on a preprocessing stage that, if skipped,
would still result in valid but erroneous source seems dangerous to me.

 m4 was not designed with embedding in a programming language in
 mind, and lots of things like macro invocation syntax and default
 quoting characters would interact very poorly with Perl.

I wouldn't classify the cpp language (#ifdef #define #include)
friendly to C either. It looks as if they happily co-exist since
invoking the C compiler automatically invokes the preprocessor.

But let's not put energy in a cpp versus m4 discussion. External macro
processors exist and can be applied by suffienciently skillful people
anyway. I think the question we must ask ourselves is: what kind of
preprocessing would we like perl to provide automatically. Also, I
think that preprocessing only plays a relevant role if we have byte
compiling. There a few advantages of a preprocessor if
preprocessing/compilation/execution are _always_ done together.

-- Johan



Re: Preprocessing (Was: Re: Recording what we decided *not* to do, and why)

2000-08-05 Thread Russ Allbery

Johan Vromans [EMAIL PROTECTED] writes:

 I fail to see this point.
 Having a program depend on a preprocessing stage that, if skipped,
 would still result in valid but erroneous source seems dangerous to me.

No, the point is more that normal Perl source is *full* of active m4
characters.  Without quoting, all your paired quotes would disappear,
comments would be stripped even when they're not actually comments but are
really regexes, m4 wouldn't understand things like Perl strings and
regexes and do substitutions where it shouldn't, etc.

The problem is not that you can skip the preprocessing stage, but rather
that as soon as you want to use m4 on a Perl program, you'd have to do a
*huge* amount of work on all the parts of the program you *don't* need to
preprocess just to be able to do things with the part that you do want to
preprocess.

cpp, on the other hand, has very few active constructs or characters, just
identifiers, function calls, and # at the beginning of a line.  It still
causes a few problems where it recognizes something it shouldn't, but it's
trivial to deal with compared to m4.

-- 
Russ Allbery ([EMAIL PROTECTED]) http://www.eyrie.org/~eagle/