home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / lang / scheme / 2858 < prev    next >
Encoding:
Internet Message Format  |  1993-01-05  |  2.5 KB

  1. Path: sparky!uunet!noc.near.net!hri.com!spool.mu.edu!umn.edu!csus.edu!netcom.com!thinman
  2. From: thinman@netcom.com (Technically Sweet)
  3. Newsgroups: comp.lang.scheme
  4. Subject: Re: Scheme & C: a universal interface
  5. Message-ID: <1993Jan5.025608.9738@netcom.com>
  6. Date: 5 Jan 93 02:56:08 GMT
  7. References: <1993Jan1.202829.11727@netcom.com> <SINYAW.93Jan4153040@starbright.smsc.sony.com>
  8. Organization: International Foundation for Internal Freedom
  9. Lines: 60
  10.  
  11. sinyaw@starbright.smsc.sony.com (Sin-Yaw Wang) writes:
  12.  
  13.  
  14. >Since you require C program to register, "Thing" is put into Scheme's name
  15. >space already.  Why not simply call these C functions directly?  Like:
  16.  
  17. >    (Thing 4) -> thing1(4)
  18. >    (Thing 5 6) -> thing2(5, 6)
  19. >    
  20.  
  21. >This way, the calling syntax is transparent.
  22.  
  23. "Thing" not put into Scheme's name space.  The interface library maintains
  24. its own list of (name, function, argument spec) tuples.  It doesn't
  25. add them to Scheme's data structures.  You can do this in Scheme:
  26.  
  27.     ; where (c-call string . args) is interior to the interpreter
  28.     (define (Thing . args)
  29.         (apply (lambda (. l) (c-call "Thing" l))))
  30.  
  31. I think would do it.
  32.  
  33. I like to be reminded when I'm using a C extension, because I have to
  34. be careful how I call it and how I use the return value.  Being forced
  35. to type (c-call "Thing" xxx) is not so bad.
  36.  
  37. >I would also like to propose the removal of "not to expose Scheme object to
  38. >C" rule.  Instead, there should be a library of C routines to parse Scheme
  39. >objects (like pair, vector, etc.).  You can specify a native Scheme object
  40. >by registering like this:
  41.  
  42. >    register("Thing", "thing_scm", 1, SCM_OBJECT);
  43.  
  44. I wanted a universal interface, where one C routine would
  45. work in any Scheme implementation that supported the
  46. interface.  If the interior structures of a particular
  47. Scheme implementation are exposed, the C code won't work
  48. under another Scheme.  Showing Scheme data structures into
  49. portable C code would require copying the entire structure
  50. into generic "struct cell" and "struct vector" data cells.
  51. These would have to be dynamically allocated and freed with
  52. each C call.  
  53.  
  54. I would prefer that Scheme code do what Scheme does best,
  55. and C code what C does best.  Respectively, manipulating 
  56. data structures, and twiddling bits.  Also, it helps to
  57. keep each extension as small and simple as possible, 
  58. because debugging it takes 5-20 times as long as
  59. debugging Scheme.
  60.  
  61. > >Lastly, "register" is a lousy choice of name.
  62.  
  63. I know, it was for illustrative purposes.
  64.  
  65.  
  66. -- 
  67.  
  68. Lance Norskog
  69. thinman@netcom.com
  70. Data is not information is not knowledge is not wisdom.
  71.