You want to be able to do something like this?

... [ ... ] curry ... alien-callback

You can't do that directly, but there are several easy workarounds
that you can encapsulate. First of all, you can memoize compiled words
that call alien-callback. This is a heavyweight approach but it gives
you full generality:

MEMO: my-callback ( obj -- word )
    [ ... do-callback ] curry '[ "int" { "int" "int" } _ "cdecl"
alien-callback ] define-temp ;

Now every time you call my-callback with a new value, the compiler
will be invoked and it will generate a new callback. This might be too
slow if you're doing this with a different object on every iteration
of a loop, or something like that.

A lighter-weight approach is that many C APIs that take callbacks can
also pass a void* "context" value that you specify at callback
registration time back to you. In that case, you can maintain a
hashtable mapping these void* to Factor objects.

Slava

On Sun, Feb 8, 2009 at 7:10 PM, Alex Drummond
<[email protected]> wrote:
> Hi, I was wondering if there is any way to pass a Factor object to C
> callback that was constructed using alien-callback.
> thanks,
> Alex
>
> ------------------------------------------------------------------------------
> Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM)
> software. With Adobe AIR, Ajax developers can use existing skills and code to
> build responsive, highly engaging applications that combine the power of local
> resources and data with the reach of the web. Download the Adobe AIR SDK and
> Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com
> _______________________________________________
> Factor-talk mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/factor-talk
>

------------------------------------------------------------------------------
Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM)
software. With Adobe AIR, Ajax developers can use existing skills and code to
build responsive, highly engaging applications that combine the power of local
resources and data with the reach of the web. Download the Adobe AIR SDK and
Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com
_______________________________________________
Factor-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to