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: felix
Subject: Re: [Chicken-users] Multiple return values
Date: Wed, 09 Oct 2002 21:39:22 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.0) Gecko/20020529

Peter Keller 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?

`define-external' is exactly what you want.
`define-location' is really just a special case of this
form.



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

[I got the hint... ;-)]

(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. :)

Oh, yes... I remember that one. ;-)

What about arrays?

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


No. `i' is an integer, but you assign a vector.


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?

It should generate more compact and more efficient code
(just slightly).



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.

Hey, you're welcome. I have to thank you and all others for
doing so much work for it. Your MP library, and the mass of code
Tony is grinding out will hopefully converge to something
genuinely competitive to other Scheme implementations (or even
other language environments).


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


You mean for locations? Unfortunately we can not properly
compute the size of a struct. Too many factors come into
play, like struct-alignment, etc. But what we need is some
kind of `sizeof' operator...


cheers,
felix






reply via email to

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