errno again

malcolm-ffi at cs.york.ac.uk malcolm-ffi at cs.york.ac.uk
Fri Dec 1 09:45:32 EST 2000


> I understand that Malcolm wants to be able to get to the
> constants, but
>
> > There are sometimes cases where specific errno values are needed. The
> > situation is no different than for other symbolic constants, like F_GETFL.
>
> I also agree with this.  Hardcoded data types should be
> avoided were possible.

Yes, I am persuaded that hard-coded datatypes tend to be bad in
this situation.  The way hsc2hs deals with constants is quite good,
and it is certainly a better, more flexible, approach.  However, I do
have some hesitation in relying on yet another pre-processing tool,
with yet another "little language" outside of Haskell itself.

Of course hsc2hs does more than just filling in constants, but for
just that one task, I wonder if we should be extending the primitive
FFI mechanism itself.  For instance, we already have "foreign label",
so what about perhaps "foreign value":

    foreign value "F_GETFL" fGetFL :: CInt

This is just off the top of my head, so I'm probably missing some
subtleties.  What do people think of this idea?  Are there some
real killer situations which would make it impossible?

Regards,
    Malcolm




More information about the FFI mailing list