#ifdef considered harmful

Wolfgang Jeltsch wolfgang at jeltsch.net
Wed Apr 7 08:34:11 EDT 2004


Am Dienstag, 6. April 2004 23:13 schrieb Carl Witty:
> On Tue, 2004-04-06 at 12:05, Wolfgang Jeltsch wrote:
> > Look at XML.  You are able to include XML code from other files but the
> > code you import must be a complete XML element.  Similarily, the brances
> > of a Haskell #ifdef should be producable out of a non-terminal, and, more
> > specific, they should be producable out of the same non-terminal.  With
> > these restrictions, one would be able to guarantee syntactical
> > correctness without evaluating the #ifdef conditions, for example.
>
> This doesn't work for one possible (and, I expect, common) use of a
> preprocessor -- if one of the branches is syntactically incorrect for
> some compilers.  For instance, perhaps one branch uses the GHC unboxed
> values extensions for performance, and the other branch uses H98 for
> portability.

Well, the preprocessor would have to be able to parse all extensions.  Maybe 
this is too difficult.

> [...]

Wolfgang



More information about the Libraries mailing list