From the other thread

Elf wrote:
John Cowan wrote:
It also occurs to me that rec and let-values and all need not expand into call-values--that's just the *portable* expansion of them.

they'll all be call-with-values on the inside, or the equivalent thereof.

Not necessarily.

I see what John is proposing here, and it makes sense to me.

We could choose values and receive (or let-values) to be the primitive calls and relegate call-with-values to the role of a somewhat inefficient wrapper, included for the sake of conformance.

- (values 1 2) could put the two values in registers or stack locations, without unnecessary consing, taking care to put the first returned value in the conventional register for single return values; - (receive (x y) ...) and the equivalent let-values form would just give names to those conventional registers or stack locations, without any destructuring; - other consuming forms could just use the first returned value and ignore the others, as they currently do; - (call-with-values) would be a bit more complex, because it would need to emulate all the calling and consing semantics, but I'd wager it's doable.

Sorry if I can't be more precise (and clever), but I don't know Chicken's internals very well (yet)

Making multiple return values as optimized as a single C call seems doable and very useful to me, even if it means optimizing for (receive) and (let-values) on the receiving side, instead of (call- with-values).

What do you think?


Tobia


_______________________________________________
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users

Reply via email to