home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.scheme
- Path: sparky!uunet!wupost!sdd.hp.com!swrinde!gatech!usenet.ins.cwru.edu!agate!spool.mu.edu!sgiblab!smsc.sony.com!sonyusa!sinyaw
- From: sinyaw@starbright.smsc.sony.com (Sin-Yaw Wang)
- Subject: Re: Scheme & C: a universal interface
- In-Reply-To: thinman@netcom.com's message of Fri, 1 Jan 1993 20:28:29 GMT
- Message-ID: <SINYAW.93Jan4153040@starbright.smsc.sony.com>
- Sender: news@smsc.sony.com (Usenet News System)
- Organization: Sony Microsystems
- References: <1993Jan1.202829.11727@netcom.com>
- Date: 4 Jan 93 15:30:40
- Lines: 44
-
- In article <1993Jan1.202829.11727@netcom.com> thinman@netcom.com (Technically Sweet) writes:
-
- Here's how a universal Scheme&C interface should work:
- from C, you register a tuple (string, function pointer,
- argument grammar) with the interface:
-
- int thing1(int);
- int thing2(int, int);
- int thingn(int nargs, int ...);
-
- register("Thing", thing1, 1, INT);
- register("Thing", thing2, 2, INT, INT);
- register("Thing", thingn, NARGS, INT);
-
- Now from Scheme, you can say: -> C mapping
-
- (c-call "Thing" 4) -> thing1(4);
- (c-call "Thing" 5 6) -> thing2(5, 6);
- (c-call "Thing" 7 8 9) -> thingn(3, 7, 8, 9);
-
-
-
-
- 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.
-
-
- 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);
-
-
- Lastly, "register" is a lousy choice of name.
-
- --
- Sin-Yaw Wang, sinyaw@smsc.sony.com, 408-944-4076
-