[cffi-devel] why is null-pointer a function?
Hoehle, Joerg-Cyril
Joerg-Cyril.Hoehle at t-systems.com
Wed Jul 11 17:39:54 UTC 2007
Tamas K Papp wonders
>I would like to ask why null-pointer is a function, not a variable...
>One reason is just curiosity, the other is that I want to know if it
>is safe to save the result of (null-pointer) in a variable and use it
>from then on (less parens, fewer function calls).
It will work, in all but one important case:
if you save your Lisp image, then restart from it and hope to continue
playing with your ffi-using application, you are guaranteed to obtain
implementation dependent results.
It may work on some Lisps, it will error out on others.
Therefore, a null-pointer function, which consistently produces a fresh
null pointer, may give less trouble, at the cost of being less
performant.
E.g. was cffi stored in your image, or did you load it before using?
Alas, the problem is not solved: if you store the null pointer in some
cell (= structure, slot, list, array etc.), save the image and restart,
you will still face implementation dependent behaviour when trying to
access that old pointer.
Regards,
Jorg Hohle.
More information about the cffi-devel
mailing list