Re: "C-pointers in FFI" question

From: Shiro Kawai <shiro_at_lava.net>
Date: Tue, 24 Apr 2001 10:30:27 -1000

From: Genady Veytsman <gena0411_at_yahoo.com>
Subject: Re: "C-pointers in FFI" question
Date: Tue, 24 Apr 2001 10:47:45 -0700 (PDT)

> Its not a problem to write such a function but its a
> very bad solution. It will slow down the program
> significantly. Consider that for every float in the
> vector (which can contain thousands of points) you
> will need to call the conversion function.

I think it depends on the application. If you need to
use all the values in that float vector, you have to
do C float->Scheme flonum conversion for every element
after all.

> IMHO its absolute must to have some convinient way to
> convert pointers (vectors) of predefined types to
> scheme vectors.

If what you want to deal with is just a vector of fixed
numeric types, there's a patch for STk-4.0.1 I wrote
that implements homogeneous numeric vector types defined
in SRFI-4.

http://www.shiro.dreamhost.com/scheme/vault/uvector-0.2.2.tgz
http://www.shiro.dreamhost.com/scheme/vault/uvector.txt (document)

This implementation is sloppy in terms of error checking.
Anyway, what you can do is to write a C extension that
gets C-ptr to a float array and set it to f32vector, for
example, and from Scheme world you can manipulate it as
a Scheme type, delaying boxing/unboxing of float numbers
until you need.

--
Shiro Kawai
  Programmer, or an inline hockey lover 
# The most important things are the hardest things to say --- Stephen King
Received on Tue Apr 24 2001 - 22:27:27 CEST

This archive was generated by hypermail 2.3.0 : Mon Jul 21 2014 - 19:38:59 CEST