FFI proposal: allow some control over the scope of C header files

Fergus Henderson fjh-mailbox-18 at galois.com
Thu May 4 18:34:40 EDT 2006

On 04-May-2006, Malcolm Wallace <Malcolm.Wallace at cs.york.ac.uk> wrote:
> Manuel M T Chakravarty <chak at cse.unsw.edu.au> wrote:
> > This leaves me with the opinion that we should really leave this as
> > pragma and not make it into FFI syntax.  It's a hint to some
> > implementations and irrelevant to others.
> Ah well, if we use that eminently sensible criterion, then the
> "safe/unsafe" annotation on foreign imports ought to be in a pragma too.
> For some implementations (yhc/nhc98) it is simply irrelevant, it is
> really a ghc-ism.  :-)

While that notion is indeed irrelevant to many implementations,
the idea is not unique to ghc.  The Mercury compiler uses
annotations "will_call_mercury" and "will_not_call_mercury"
which are very similar to ghc's safe/unsafe.

If that design criteria had been applied to C and C++, then the "register"
and "inline" keywords would not exist.  But those have been useful for
many portable applications.

I think it is reasonable to standardize pragmas if there is a reasonable
likelihood that multiple implementations will be able to make use of them,
as was the case for "register" and "inline", even if many implementations
will ignore them.  Whether this is likely for safe/unsafe, I don't know,
but the Mercury data point suggests that it may be.


Fergus J. Henderson                 |  "I have always known that the pursuit
Galois Connections, Inc.            |  of excellence is a lethal habit"
Phone: +1 503 626 6616              |     -- the last words of T. S. Garp.

More information about the Haskell-prime mailing list