[plt-scheme] Specifying a callback that takes a f64vector

From: Eli Barzilay (eli at barzilay.org)
Date: Thu Apr 30 11:22:38 EDT 2009

On Apr 30, Noel Welsh wrote:
> On Thu, Apr 30, 2009 at 4:11 PM, Eli Barzilay <eli at barzilay.org> wrote:
> >> typedef void (lm_evaluate_ftype) (double *par, int m_dat, double *fvec,
> >>                                 void *data, int *info);
> >
> > This declaration suffers from the usual header file problem: it
> > doesn't specify which values are inputs and which are outputs...
> 
> fvec is output; all others are input.

So it should have an `o' flag.


> > Which part exactly?  What looks like it's almost definitely wrong
> > is that this function returns void, and no other value, so it
> > would be pretty useless as defined.  Perhaps you're confusing
> > input and output annotations?  (`i' mode is for a vector that is
> > an input to the function.)
> 
> The typedef is a function pointer that is called by C code. I just
> want the function pointer to in turn call Scheme code. So
> rearranging parameters to be returned values is not necessary or
> desirable as this will break the calling code.

I don't unrestand what you're saying here.  Your type definition
specifies a function that returns void, and doesn't write values in
any pointers (since the pointers are all input pointers).  So it's a
function that has no way to communicate values back to its caller,
whether it's a C callout or a Scheme callback.

-- 
          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                  http://www.barzilay.org/                 Maze is Life!


Posted on the users mailing list.