[Haskell-cafe] A restricted subset of CPP included in a revision
of Haskell 98
Sven Panne
sven.panne at aedion.de
Sun Nov 5 08:32:40 EST 2006
[ I'm just working through a large backlog of mails, so the original message
is a bit old... :-) ]
Am Sonntag, 20. August 2006 22:37 schrieb Henning Thielemann:
> On Thu, 17 Aug 2006, Brian Smith wrote:
> [...]
> I think there should be more effort to avoid CPP completely. 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. [...]
That's a nice theory, but this doesn't work in practice, at least not for me.
The problem in my OpenGL/GLUT/... bindings is that the calling convention to
the native libraries is different on Windows, and there is no "Haskell way"
to parametrize this. Therefore using a preprocessor is the only sane way I
see here. Having to duplicate e.g. 567 "foreign imports" just to avoid CPP in
the OpenGL package is a rather bad tradeoff IMHO. Almost everything is better
than redundancy, even CPP...
Another use of CPP in the OpenGL package is to access OpenGL extension entry
points. Here CPP is used to generate a 'foreign import "dynamic"' and two
Haskell functions per extension entry. Perhaps this could be done via TH, but
this would limit the portability, again a bad tradeoff.
I would be glad if there were other ways to achieve these things, but I fail
to see them.
Cheers,
S.
More information about the Haskell-Cafe
mailing list