[Top][All Lists]

[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: Thu, 10 Oct 2002 20:21:46 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.0) Gecko/20020529

Peter Keller wrote:

I think (if I understand your and my argument correctly) that I only
want a unification of the two ideas into a single syntax sine I think we
are agreeing.

For example(using the foobar external definition example):

Using locations to reference a single variable:
(let-location ((i integer 42))
        (foobar (location i))
        (print "i is now 43: " i))

Using s32vector to reference a single variable:
(let ((i (s32vector 42)))
        (foobar i)
        (print "i is now 43: " (s32vector-ref i 0)))

To me, those should be the same since they represent the same thing from the
point of view of the C interface, whose prototype is void foobar(int*) no
matter which method you use above.

I very much like your (location ...) abstraction however. Maybe it can be
made more general.

(location 's32vector var)
(location 'integer var)
(location 'unsigned-int var)

Now, let-location doesn't even exist(if I understand it correctly),
and the compiler possibly at compile time can check to see if this is
true with the binding passed to it.

Hm. You can not compute a pointer from a normal Scheme data object
(the s32vector), because the object may move during GC, invalidating
the pointer. What you can do is create a locative from that.
The confusing point here is that the s32vector type is really just
a normal value, but its treated specially when passed as an argument
to a foreign procedure.


reply via email to

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