chicken-users
[Top][All Lists]
Advanced

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

Re: [Chicken-users] FFI multiple value return


From: felix
Subject: Re: [Chicken-users] FFI multiple value return
Date: Sun, 6 Oct 2002 23:04:39 +0200

>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.


Hm. I'm not sure. This would need a lot of shifting around of values
to/from result structures. Values would be cleaner, even if the arguments
are actually wrapped in a data-structure. To implement the above scheme,
we have to generate wrapper code around the invocation, which
allocates space for the results and passes an implicit argument (the result
buffer). I have to check out the code and see how this can be handled.


cheers,
felix






reply via email to

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