Hi!

I believe, I have asked this same question a couple of times already on this 
list but may be the phrasing was incorrect. Let me ask it again and hope that 
somebody replies at least .

I am wondering how to use callbacks with c-library calls. That is how to pass 
a forth word to a library function that expects a pointer to a function. For 
example sort routine would need a *compare* function which takes two 
arguments and returns boolean. Thus , a general description of the following 
would be really helpful:

1. How my forth word should be written in order to be able to accept input 
parameters when used as a callback. (e.g. two objects of the same type for a 
sorting library function)

2. How this word should be written in order to return a value when called by a 
library function. (e.g. boolean value of the *compare* word)

For a particular example I am working on library bindings to GSL together with 
a set of words realizing the scientific library's functionality in a simplier 
way. GSL has a function gsl_set_error_handler which accepts a function with 
the following prototype:

void handler (const char * reason,
              const char * file,
              int line,
              int gsl_errno)

It would be nice if this can be used as an example of explaining callback 
implementation in bigforth (you can get my gsl bindings (working version) from 
www-bcl.cs.unm.edu/~pliz/gsl.tgz )

PS The only place in bigforth trunk where I was able to find c-callbacks is in 
3d-turtle.fs. Unfortunately, either library functions are used for callbacks 
or two words written in assembly which is not very helpful to me without some 
comments and explanations.

Even if there is no standard way to do such thing in bigfroth - A way would be 
very interesting to look at.

Thanks!

-- 
Sergey

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to