[Haskell-cafe] A restricted subset of CPP included in a revisionof Haskell 98

Brian Hulley brianh at metamilk.com
Sun Aug 20 21:42:26 EDT 2006


Henning Thielemann wrote:
> On Thu, 17 Aug 2006, Brian Smith wrote:
>
>> I find it strange that right now almost every Haskell program
>> directly or indirectly (through FPTOOLS) depends on CPP, yet there
>> is no effort to replace CPP with something better or standardize its
>> usage in Haskell.
>
> I think there should be more effort to avoid CPP completely.

I agree, especially as I'm trying to write an editor for Haskell which will 
certainly not cope with CPP at all! ;-)

The reason it would not cope is that CPP turns what would otherwise be one 
program/module/library into several programs/modules/libraries which 
simultaneously co-exist in the same text in a rather uneasy and vague 
relationship, and what's even worse: the same module can have multiple 
meanings in the *same* program depending on use of #ifdef #undef etc, thus 
making code navigation quite impossible: the meaning of each module now 
depends on how you got there and might even be different the second time 
round...

It is also notoriously difficult for people to understand code full of 
#ifdef's.

> My experiences with Modula-3 are, that you can nicely separate
> special-purpose stuff into modules which are included depending on
> some conditions. Say you want the same module both for Windows and
> Unix, you provide directories WIN32 and POSIX containing
> implementations with the same interface and then the make system can
> choose the appropriate directory.

It would also be nice to have a very simple build system instead of 
requiring makefiles ie so any Haskell program, even ones involving other 
tools such as attribute grammar desugaring, could be built using ghc --make 
(or some other tool which took only the source + description of available 
tools as input).

I think the acid test would be to reach a point where anyone can download 
the source for some large program such as GHC and just type ghc --make Main 
and expect the program to be built in one pass with no problems.

Regards, Brian.
-- 
Logic empowers us and Love gives us purpose.
Yet still phantoms restless for eras long past,
congealed in the present in unthought forms,
strive mightily unseen to destroy us.

http://www.metamilk.com 



More information about the Haskell-Cafe mailing list