home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!noc.near.net!hri.com!spool.mu.edu!umn.edu!csus.edu!netcom.com!thinman
- From: thinman@netcom.com (Technically Sweet)
- Newsgroups: comp.lang.scheme
- Subject: Re: Scheme & C: a universal interface
- Message-ID: <1993Jan5.025608.9738@netcom.com>
- Date: 5 Jan 93 02:56:08 GMT
- References: <1993Jan1.202829.11727@netcom.com> <SINYAW.93Jan4153040@starbright.smsc.sony.com>
- Organization: International Foundation for Internal Freedom
- Lines: 60
-
- sinyaw@starbright.smsc.sony.com (Sin-Yaw Wang) writes:
-
-
- >Since you require C program to register, "Thing" is put into Scheme's name
- >space already. Why not simply call these C functions directly? Like:
-
- > (Thing 4) -> thing1(4)
- > (Thing 5 6) -> thing2(5, 6)
- >
-
- >This way, the calling syntax is transparent.
-
- "Thing" not put into Scheme's name space. The interface library maintains
- its own list of (name, function, argument spec) tuples. It doesn't
- add them to Scheme's data structures. You can do this in Scheme:
-
- ; where (c-call string . args) is interior to the interpreter
- (define (Thing . args)
- (apply (lambda (. l) (c-call "Thing" l))))
-
- I think would do it.
-
- I like to be reminded when I'm using a C extension, because I have to
- be careful how I call it and how I use the return value. Being forced
- to type (c-call "Thing" xxx) is not so bad.
-
- >I would also like to propose the removal of "not to expose Scheme object to
- >C" rule. Instead, there should be a library of C routines to parse Scheme
- >objects (like pair, vector, etc.). You can specify a native Scheme object
- >by registering like this:
-
- > register("Thing", "thing_scm", 1, SCM_OBJECT);
-
- I wanted a universal interface, where one C routine would
- work in any Scheme implementation that supported the
- interface. If the interior structures of a particular
- Scheme implementation are exposed, the C code won't work
- under another Scheme. Showing Scheme data structures into
- portable C code would require copying the entire structure
- into generic "struct cell" and "struct vector" data cells.
- These would have to be dynamically allocated and freed with
- each C call.
-
- I would prefer that Scheme code do what Scheme does best,
- and C code what C does best. Respectively, manipulating
- data structures, and twiddling bits. Also, it helps to
- keep each extension as small and simple as possible,
- because debugging it takes 5-20 times as long as
- debugging Scheme.
-
- > >Lastly, "register" is a lousy choice of name.
-
- I know, it was for illustrative purposes.
-
-
- --
-
- Lance Norskog
- thinman@netcom.com
- Data is not information is not knowledge is not wisdom.
-