Newsgroups: comp.lang.scheme
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!news2.near.net!noc.near.net!paperboy.wellfleet.com!news-feed-1.peachnet.edu!gatech!swrinde!sgiblab!pacbell.com!amdahl!netcomsv!netcom.com!bakul
From: bakul@netcom.com (Bakul Shah)
Subject: FFI & Scheme (was: scm On Mac)
Message-ID: <bakulCxvu4n.BL4@netcom.com>
Organization: NETCOM On-line Communication Services (408 261-4700 guest)
References: <jrvincent-1110941643260001@jrvincent.con.wesleyan.edu> 	<SCHWARTZ.94Oct13123529@roke.cse.psu.edu> 	<JAFFER.94Oct16121109@jacal.zurich.ai.mit.edu> 	<SCHWARTZ.94Oct16154338@galapagos.cse.psu.edu> 	<37tglb$r0t@news.cs.tu-berlin.de> <BLUME.94Oct17094023@aleph.cs.princeton.edu>
Date: Tue, 18 Oct 1994 19:00:20 GMT
Lines: 36

blume@aleph.cs.princeton.edu (Matthias Blume) writes:

>[Of course, one way to implement the SXI (Schemely X11 Interface) is
>to have access to the raw C interface in Scheme (i.e. in some
>un-schemely fashion), which will have to be wrapped and hidden by a
>certain amount of Scheme code to make it look less ugly.]

IMHO this is the way to go.  Once there is a `raw' foreign
function interface we can pretty up interfaces to specific
libraries; make them Scheme friendly.

[On the other hand, it may be easier to define a schemely
interface to POSIX, X11 etc. that works across all Scheme
implementations compared to a FFI that will.  On the other other
hand, *standardizing* anything without sufficient experience in
it seems like a recipe for a bad standard, not to mention the
fact standardizing anything substantial in Scheme has not
succeeded so far]

The issues in FFI (as I see them) are
- dealing C libraries' namespace
- Mapping C data types to Scheme
- Callbacks from C to Scheme; how to deal with closures
- Interaction of GC with C code

So here is the challenge:  Can they be solved in a machine
independent way?  Can they be solved for the commonly available
implementations such that I can make a scheme program employing
some C facility work on atleast two of them without any change?

It'll be nice to have a c2scmh & h2scmh (ala c2ph & h2ph of perl)
that translates C structs (generated by cc -g -S stabs) and C
header files to Scheme usable ``structures'' (the irony is that
it'll be easier to write these tools in perl).

Bakul Shah
