chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Chicken-users] FFI multiple value return


From: tonyg
Subject: [Chicken-users] FFI multiple value return
Date: Sun, 6 Oct 2002 14:27:19 +0100
User-agent: Mutt/1.2.5i

[Peter wrote:]
> as a result. I'm happy to add code to do typechecking and stuff, But I 
> really just want a super clean interface to foobar().

This comes up when wrapping GTK+ 2.0, as well. There's the odd
function that takes a guint* (etc) and wants to fill in the result.

Felix - what do you think about some kind of way of specifying that a
foreign-lambda may return *multiple values*, a la r5rs
call-with-values etc?

Perhaps something like

        (foreign-lambda int "foo"
                        int
                        int
                        (long return)
                        c-string
                        (c-string return))

having signature (int x int x c-string) -> (int x long x
c-string)... I don't know if returning r5rs values or a list of
results would be better. Probably values.

        (foreign-lambda* (int long c-string)
                         ((int arg1)
                          (int arg2)
                          (c-string arg3))
                         "do_computation();"
                         "other_stuff();"
                         "result.r0 = some_int;"
                         "result.r1 = some_long;"
                         "result.r2 = some_string;"
                         "return(result);")

Chicken could manage the structures and all the marshaling and finicky
GC issues.

Tony




reply via email to

[Prev in Thread] Current Thread [Next in Thread]