ANN: H98 FFI Addendum 1.0, Release Candidate 13

Ross Paterson ross at soi.city.ac.uk
Wed Nov 5 06:00:51 EST 2003


On Wed, Nov 05, 2003 at 07:24:03PM +1100, Manuel M T Chakravarty wrote:
> > Do you intend to wait until an implementation of this is committed
> > to CVS before finalizing the spec?  (I hope so.)
> 
> We already have a reference implementation (by John
> Meacham), which is available online.  I am not sure whether
> having it in CVS is going to add much.

I think it will improve the chances of catching problems in the details,
which are a special risk when adding sizeable things late in the process.

Looking through that implementation, I note (in relation to Simon's
question) that the CWString functions are only provided if the C
compiler defines __STDC_ISO_10646__ (so the conversion is fromIntegral).
Should the spec say that?  If not, and the conversion is possibly
locate-dependent, you'd need a counterpart of charIsRepresentable
for the wide representation.

You have the bit about unrepresentable Chars becoming '?' in the legacy
byte string part.  I think it belongs in locale-dependent CString part.
(I believe the single byte conversion discards all but the lower 8 bits,
though there's probably no need to say that.)

Other minor things (about old stuff):

* I think the description of newCString, etc needs to say that the
  memory so allocated may be released using MarshalAlloc.free.

* CString is said to be NUL-terminated, but presumably CStringLen is not
  assumed to have a NUL.  Perhaps this would be clarified by defining
  it as (Ptr CChar, Int) instead of (CString, Int) and similarly for CWString.


More information about the FFI mailing list