This is the mail archive of the guile@cygnus.com mailing list for the guile project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Date: Wed, 17 Dec 1997 18:19:25 -0500 (EST) From: Clifford Beshers <beshers@cs.columbia.edu> Sender: owner-guile@cygnus.com Precedence: bulk >From everything I've seen in documentation and source, uniform arrays in Guile and SCM are C arrays with some bookkeeping information at the front and a set of access routines. The advantage cited in the documentation is that these arrays take less space than conventional vectors, but surely they are also designed for efficiency and Yes. Someday, SCM will support a full set of parallelized operations (a la APL) for uniform arrays. Radey Shouman has coded some of this in SCM/ramap.c. interoperability purposes, as well? Interoperability is harder, isn't it? Are IEEE floating point numbers portable between different endian machines? I am waiting for the dust to settle on character sets -- I expect difficulty in that area as well. Given a uniform array, I want to obtain a pointer to the actual array and pass it to a C function which is expecting something of type X*, where X is one of char, short, long, float, double, etc. SCM/rope.c has that routine, called scm_addr() [can someone tell me why scm_addr doesn't appear in scm.info's function index?] - Function: unsigned long scm_addr (SCM ARGS, char *S_NAME) Returns a pointer (cast to an `unsigned long') to the storage corresponding to the location accessed by `aref(CAR(args),CDR(args))'. The string S_NAME is used in any messages from error calls by `scm_addr'. `scm_addr' is useful for performing C operations on strings or other uniform arrays (*note Uniform Array::.). *Note:* While you use a pointer returned from `scm_addr' you must keep a pointer to the associated `SCM' object in a stack allocated variable or GC-protected location in order to assure that SCM does not reuse that storage before you are done with it. For extra giggles, you can return that address to SCM: static char s_scm_address[] = "address"; SCM scm_address(args) SCM args; { return ulong2num(scm_addr(args, s_scm_address)); } However, I only want to do this if it is considered to be one of the supported operations. Is there, and will there always be, a way to get a C pointer to this array, and will the array always be identically to the C types char*, short*, etc. With the exception of shared-arrays, SCM will. What would make sense to return for a shared-array? I'm assuming, of course, that this will happen in an external routine, not in Scheme. That is, I have a external function written in C which accepts uniform arrays, extracts the pointer, then passes it on to another C routine from some library. Speaking of interoperability, it seems silly to be duplicating a lot of work between SCM and GUILE. At least as of guile-1.2, it looks as though non-core source files could work with both. I am willing to change names in SCM. Does someone want to investigate the costs and benefits of becoming compatible?