chicken-users
[Top][All Lists]
Advanced

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

Re: [Chicken-users] multiple values in chicken


From: felix winkelmann
Subject: Re: [Chicken-users] multiple values in chicken
Date: Mon, 4 Feb 2008 07:19:41 +0100

On Feb 1, 2008 5:46 PM, Will Farr <address@hidden> wrote:
> Isn't a call to values completely equivalent to:
>
> (values v1 ...) => (call/cc (lambda (k) (k v1 ...)))
>
> so
>
> (define (values . rest) (call/cc (lambda (k) (apply k rest))))
>
> (which seems like the point that John is making)?  Since call/cc is
> free in Chicken, wouldn't this be as fast as any procedure call (well,
> any procedure call which involves a procedure with a rest list)?  Why
> mess with all the C_values etc?  Or is this some sort of
> standards-compliance issue (I see a check for a "values continuation"
> in runtime.c)?

Continuation procedures generates by the compiler during CPS conversion
are not completely equivalent to normal "user" procedures: they do less
error and stack checking and always expect a single result.
This speeds up the normal case but needs extra checking and closure
creation when doing multiple value returns. It can only be deduced at
runtime whether a continuation is multiple-value aware or not and this,
together with the need for constructing C function calls (itself always
the source of some overhead, even with the apply hack) shows in the
relative complexity taking place in this situation (Some gcc guru might
be able to exploit __bultin_apply[_args], but not me).


cheers,
felix




reply via email to

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