Newsgroups: comp.lang.dylan
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!news2.near.net!howland.reston.ans.net!pipex!uunet!sytex!smcl
From: smcl@sytex.com (Scott McLoughlin)
Subject: Re: The C/Dylan interface
Message-ID: <ywRwVc1w165w@sytex.com>
Sender: bbs@sytex.com
Organization: Sytex Access Ltd.
References: <aberno-1611941121310001@lyapunov.stanford.edu>
Date: Thu, 17 Nov 1994 00:15:45 GMT
Lines: 43

aberno@genome.stanford.edu (Anthony Berno) writes:

> Most of these functions take pointers to arrays of numbers. Will it be
> possible to use such functions from within Dylan? I can see how one might
> interface with C modules whose functions take simple arguments like floats
> and strings, but I do not see, given the way everything is an object in
> Dylan, how one can call a C function that expects an array to be
> represented in a particular way.
> 

Howdy,
        So long as one's not interested in portability or
elegance or convenience.... It's not too tough for any 
implementor to offer basic field access to a chunk of
raw binary data with conversions to/from the native
numeric formats (boxed double-floats, fixnums, characters,
whatever).  We do this in LinkLisp (which will be be out
for beta testing Real Soon Now) with a simple set of 
primitive fetchers/storers to do sign extended/unsigned
fetches of 8bit and 16 bit numbers, 32 bit numbers, and
single/double floats, etc.  Forth programmers have moved
world with such a tiny fulcrum for over a decade 
( @ and ! ) and many larger full CL's that support CL's
remarkable array machinery still provide such lower 
level primitives.
        If one is interested in elegance and convenience,
macro wrappers are pretty simple to write to cobble up
a pretty decent binary structure definition facillity.
For example, my partner prefers a wholly compile time
macroexpansion based facillity (like setf) that doesn't
add oodles of functions to the global namespace. I'm
starting to come around to his point of view, since 
function redefinition/forward referencing isn't so
important for these low level access operations anyway, 
and speed is.
        Anyway, if Apple is parsing C header files, 
I don't think you'll have much trouble passing 2D
arrays of double-floats off to C functions.

=============================================
Scott McLoughlin
Conscious Computing
=============================================
