type checks (was: CLISP typed foreign references)
"Hoehle, Joerg-Cyril" <[email protected]> Wed, 3 Apr 2002 10:45:45 +0200
| Newsgroups | gmane.lisp.uffi.general |
|---|---|
| Message-ID | <[email protected]> |
Von: Kevin Rosenberg wrote: > Thanks for the detailed information. I'll reread the > imp-notes for CLISP and think about your message. I would I think it doesn't mention the properties of FOREIGN-ADDRESS etc. objects. > Looking at foreign-variable and foreign-address, perhaps I > can plug in my own malloc and free to allocate arbitrary > objects outside of a function call. Don't do malloc+free, I'll do. I'm already thinking about WITH-ALIEN/STACK-ALLOCATION for CLISP. I already have a MALLOC hack (but no free yet). The problem to me, however, is not malloc+free. It's matching C type information between foreign objects and function signatures. So far, I don't seem forward to implementing C subtype style testing in Lisp. OTOH, if I declare (function GETENV (* char)) and pass a typeless foreign pointer (or worse, an integer like in ACL), I'm even less safe than working in plain ANSI-C. I don't like that. Any ideas? (C-subtypep '(c-ptr (c-array character <N>)) 'c-string) ->? (C-subtypep 'c-string '(c-ptr-null (c-array-max character <N>))) ->? (C-subtypep '(c-array-ptr character) 'c-string) ->? Worse-is-better => provide version which does no checking so people can start working, then think about improvements and a better world. BTW, thanks for putting my draft of an article on FFI design on the server. Regards, Jorg Hohle.