chicken-users
[Top][All Lists]
Advanced

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

Re: [Chicken-users] Multiple return values


From: Peter Keller
Subject: Re: [Chicken-users] Multiple return values
Date: Wed, 9 Oct 2002 09:56:36 -0500
User-agent: Mutt/1.2i

Hello,

On Wed, Oct 09, 2002 at 09:22:55AM +0200, Felix wrote:
> [syntax] (define-location NAME TYPE [INIT])
>    the same as `define-external', but not visible
>    outside the current file.

Why did you make this choice to keep the variable local to the current
file? What would happen if you lifted this restriction?

> [syntax] (let-location ((NAME TYPE [INIT]) ...) BODY ...)
>    creates a lexically bound C variable.

I like the [INIT] bit since it allows you to translate between scheme
objects and C types.

Though, suppose something like this happens:
(define foo 134324234234) ;; Suppose you used my GNU MP FFI...
(let-location ((i int foo))
        ...)

Now, chicken has to check to see if foo will "fit" into the integer i, if not
then i has to get assigned INT_MAX or something like that.
However, since chicken currently can't support numbers larger than a C_word
it won't be a problem, but it should be thought about. And, uh, what about
long long. :)

> (declare (foreign-declare "#include <math.h>"))
> 
> (define modf (foreign-lambda double "modf" double (pointer double)))
> 
> (let-location ([i double])
>    (let ([f (modf 1.99 (location i))])
>      (print "i: " i ", f: " f) ) )

Nice. 

What about arrays?

;; does this make sense?
(let-location ((i integer (s32vector 1 2 3 4 5 6 7)))
        ...)

> I still have to run a couple of tests (generated
> FFI code has been slightly improved), but this should
> be available soon.

Will this affect current FFI code?

> Notes:
> - the types given to define-location/let-location
>    have to have known sizes (only simple or pointer types)

I, and I'm sure others, really appreciate the additions you are doing
to chicken in this area, Felix. Thank you.

-pete

P.S. I suppose if I pester enough, a solution for structures might be
figured out as well? *grin*




reply via email to

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