Path: utzoo!attcan!uunet!mcvax!ukc!etive!aiva!jeff From: jeff@aiva.ed.ac.uk (Jeff Dalton) Newsgroups: comp.lang.lisp Subject: Re: foreign functions to KCL Message-ID: <661@aiva.ed.ac.uk> Date: 15 Nov 88 18:38:35 GMT References: <5363@medusa.cs.purdue.edu> <6381@june.cs.washington.edu> Reply-To: jeff@uk.ac.ed.aiva (Jeff Dalton) Organization: Dept. of AI, Univ. of Edinburgh, UK Lines: 32 In article <6381@june.cs.washington.edu> whaley@uw-june.UUCP (Ken Whaley) writes: >The good news is that it's easy to incorporate C functions into >KCL. The bad news is that unless you want to write C code that can't >be used outside of the KCL environment, then you are constrained to use >certain input parameter and function return types. That's more or less true if you want to return something to be manipulated in Lisp -- it has to be one of the objects Lisp knows about. However, you can malloc things, define (Lisp) procedures that call C procedures to manipulate such objects, and so on. It's just that there isn't a "C structure" facility built-in. >:NOTE: The KCL documentation says that the following is specific > to the BSD version of KCL. I think only some it it (such as si:faslink) is just for BSD. But since I almost always use BSD I can't say for sure that it works. Nonetheless, since KCl compiles to C, some kind of C interface is surely possible. >Oh, and I've only managed to get this working with non-pointer types. >I haven't experimented with structs, either. You can pass in, manipulate, >and return arbitrary LISP objects (KCL itself is written in C....), but >that sort of information is, as far as I know, undocumented, and you'd >have to dig through the source code to figure it out. Basically, Lisp objects are pointers to a union of structs. So each Lisp object corresponds to some C struct. The structs, union, etc. are defined in object.h and the subset used by compiled code is in cmpinclude.h. -- Jeff