[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-users] multiple values in chicken
From: |
John Cowan |
Subject: |
Re: [Chicken-users] multiple values in chicken |
Date: |
Fri, 1 Feb 2008 10:18:52 -0500 |
User-agent: |
Mutt/1.5.13 (2006-08-11) |
Zbigniew scripsit:
> A multiple-value call takes the following route under Chicken:
> C_call_with_values -> C_do_apply -> C_values -> values_continuation ->
> C_do_apply. A single-value call is compiled to a function call. You
> can see why returning a single list value and destructuring it should
> be a lot faster.
Et Felix confirmavit:
> Multiple values involve more checking that returning an explicit
> data structure, because the receiving continuation may or may
> not be multiple-value aware. Returning a single result from a function
> is a more fundamental operation than handling multiple-value
> continuations, so will always be faster.
It occurs to me that one place where multiple argument and multiple
values are not dual in Scheme-as-we-know-it is that lambda is syntax
but values is a function, so it's reliably knowable at compile time how
many arguments a Scheme function requires (even if one is a rest list)
but not how many values it returns.
How about a little extension to lambda, whereby if the first (or last,
or any) item in the lambda-list is a fixnum constant, that is taken as a
reliable declaration of how many values it returns? (I'm not wedded to
this syntax, if someone can think of something better.) This would cause
any excess values to be discarded and not passed to the continuation, and
any missing values to become void objects.
In that way, the continuation could be compiled as a simple C function
with a fixed number of arguments, making it literally just as fast as
single-argument continuations and short-circuiting the chain of calls
shown above.
--
I now introduce Professor Smullyan, John Cowan
who will prove to you that either address@hidden
he doesn't exist or you don't exist, http://www.ccil.org/~cowan
but you won't know which. --Melvin Fitting
- Re: [Chicken-users] multiple values in chicken, (continued)
Re: [Chicken-users] multiple values in chicken, Zbigniew, 2008/02/01
Re: [Chicken-users] multiple values in chicken, F. Wittenberger, 2008/02/01
Re: [Chicken-users] multiple values in chicken,
John Cowan <=
Re: [Chicken-users] multiple values in chicken, felix winkelmann, 2008/02/04
Re: [Chicken-users] multiple values in chicken, John Cowan, 2008/02/04
Re: [Chicken-users] multiple values in chicken, felix winkelmann, 2008/02/04
Re: [Chicken-users] multiple values in chicken, John Cowan, 2008/02/04
Re: [Chicken-users] multiple values in chicken, Graham Fawcett, 2008/02/04