#ifdef considered harmful

Isaac Jones ijones at syntaxpolice.org
Tue Apr 6 15:36:17 EDT 2004

Wolfgang Jeltsch <wolfgang at jeltsch.net> writes:

> Am Dienstag, 6. April 2004 20:13 schrieb Isaac Jones:
>> [...]
>> >> (d) For those differences that cannot be eliminated implementing (in
>> >> Haskell) a portable preprocessor that can ship as part of every Haskell
>> >> environment?
>> >
>> > I think this is ultimately going to be the most viable solution.
>> > Let's write a simple 'hspp' (in Haskell?) that is backward compatible
>> > with 'cpp -traditional' (although we might also design a newer nicer
>> > syntax too), and distribute it with every compiler.  It can't be
>> > too difficult, surely?  Half of the cpp parsing/selection code is
>> > already available within hmake.  I would take on the project myself,
>> > if I had time.
>> I agree that this should be possible with the hmake code.  FWIW, I
>> have, in fact, already teased that functionality out (to a small
>> degree) and made it available in my work-in-progress HMake API.
> 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?

> The latter would be better, 


> IMO; the former would probably have little or no advantage over cpp.

>From the point of view of this conversation, the advantage would be
that it's implemented in pure Haskell, so you don't need external
tools that may be difficult to get on your system.

The reason it's there in Distribution.Build is so that wrapper build
systems (whether they be implemented in Make or in Haskell) can
utilize a common interface.



More information about the Libraries mailing list