(Hi Joerg,)
On Tue, 2005-12-20 at 16:15 +0100, Hoehle, Joerg-Cyril wrote:
Luis Oliveira
Let me see if I got this straight, your proposal is that the :pointer type may or may not accept NIL (but it should documented as non-portable),
No. :pointer is documented to only accept valid CFFI pointers. These are documented as opaque. Code using NIL is in error, as well as code using 0.
I agree completely with this. It's easy to define a translator on :pointer to convert NIL to and from null pointers if this is desired.
Another useful addition is a pointer type which does not accept a null-pointer, but signals an error instead, or just specifies that "passing (null-pointer) is an error". This type can be used in function declarations. The effect is two-fold: a) just from seeing the declaration, you know that NULL is not allowed. b) optionally, the transformers could check for this at run-time.
I'm not certain I see how you could do this at any other time besides run-time, except for maybe some cases where the function argument is CONSTANTP and evaluates to nil in some compiler-macro or so.
This is the sort of stuff that should be easy to define in "userland" using the type translator mechanism, but I can see that this could be usefully predefined by CFFI.
James