Placement of OPTION pragmas

Malcolm Wallace Malcolm.Wallace at cs.york.ac.uk
Fri Sep 19 11:03:50 EDT 2003


nilsson at cs.yale.edu writes:

>                                     Moreover, there is only one first
> line, and assuming some kind of language pragma is introduced, and assuming
> Simon Marlow goes ahead and introduces GHC_OPTIONS, and the other
> implementors goes ahead and introduces HUGS_OPTIONS, NHC_OPTIONS, etc.,
> insisting on all of these being on the first line is obviously not going to
> work.

As it happens, nhc98 already interprets some pragmas in this manner:
    {-# OPTIONS_COMPILE #-}
and
    {-# OPTIONS_LINK #-}
The former gives options for this module alone, whereas the latter
are accumulated when linking several modules together into an
executable, to permit for instance a binding to a foreign library to
be conveniently expressed in the single place where it is most relevant.

However, clearly, there are already two of these pragmas, and as
Henrik points out they also cannot both be in the first line!  The way
nhc98 deals with this is to do a quick and dirty parse of the source
file in the driver script (i.e. grep "OPTIONS..." or equivalent),
which information is then used to turn on/off language features in
the invocation of the compiler proper.  Seems easy enough.

Regards,
    Malcolm


More information about the Glasgow-haskell-users mailing list