No subject

Mon Feb 21 07:28:50 EST 2005

  castPtrToStablePtr Ptr.nullPtr

My reading of the description of freeStablePtr is that it is perfectly
legal to pass around a (void*)0 as an HsStablePtr and to hand that to
freeStablePtr and castStablePtrToPtr and expect something meaningful
to happen.  

(My personal leanings with anything resembling a C pointer have always
been to use some variant of

  Maybe Addr
  Maybe (Ptr a)
  Maybe (FunPtr a)
  Maybe (StablePtr a)

if the pointer can possibly be null.  It turns out that many functions
assume their argument cannot be null or guarantee that their result is
not null and this both catches errors and reminds the programmer to think
about the null case.)

> Nevertheless, deRefStablePtr should raise an exception when it finds
> an invalid stable pointer.

Which brings me back to my question: _which_ exception should it raise?

Alastair Reid        reid at

More information about the FFI mailing list