#ifdef considered harmful

Wolfgang Jeltsch wolfgang at jeltsch.net
Tue Apr 6 22:05:07 EDT 2004

Am Dienstag, 6. April 2004 20:36 schrieben Sie:
> [...]

> > Will such a preprocessor work on source code like cpp does or on a syntax
> > tree?
> On source code, at least for now.  There's no plan, ATM, to include a
> parser with Distribution.Build.  It could be useful, but I expect that
> we want to pass such work onto the compilers / interpreters.
> Can you explain the syntax tree you picture for this?  Where will such
> a tree come from?

I have no detailed picture at the moment.

> > The latter would be better,
> Why?

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.

> [...]


More information about the Libraries mailing list