A non-consing arbitrary number of multiple return values?
From: Adam Warner (usenet_at_consulting.net.nz)
Date: 01/26/05
- Next message: Jens Axel Søgaard: "Re: A non-consing arbitrary number of multiple return values?"
- Previous message: Rob Warnock: "Re: Lisps' popularity"
- Next in thread: Jens Axel Søgaard: "Re: A non-consing arbitrary number of multiple return values?"
- Reply: Jens Axel Søgaard: "Re: A non-consing arbitrary number of multiple return values?"
- Reply: Frode Vatvedt Fjeld: "Re: A non-consing arbitrary number of multiple return values?"
- Maybe reply: Florian Weimer: "Re: A non-consing arbitrary number of multiple return values?"
- Reply: Bruno Haible: "Re: A non-consing arbitrary number of multiple return values?"
- Reply: Duane Rettig: "Re: A non-consing arbitrary number of multiple return values?"
- Maybe reply: Barry Margolin: "Re: A non-consing arbitrary number of multiple return values?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 26 Jan 2005 23:56:30 +1300
Hi all,
Have I correctly concluded that it is impossible for a /single stack/
function interface to return an arbitrary number of values without consing?
My reasoning is thus:
1. The function caller places n arguments on the stack and informs the
function callee of their location and number. No problem so far.
2. The callee then reserves space on the stack "above" the arguments for
local lexical variables. The amount of space to reserve can be accurately
determined at compile time. Still no problem.
3. The number of values the callee returns may only be known at run time,
and crucially may only be known by the callee once it is time to return to
the caller. This is too late to reserve space on the stack when the caller
may itself call a function before returning. At the time it calls a
subfunction the callee needs to allocate space for its arguments. But it
can't allocate the arguments when it doesn't know how much space to
reserve for multiple return values.
Maintaining two stacks--one for arguments and local variables and the
other for multiple return values--seems natural but costly.
Another potential solution would be to only support a low number of
multiple return values, such as the minimum of 20 as specified by ANSI
Common Lisp (multiple-values-limit). At steps 1, 2 or 3 one would always
reserve space for up to 20 return values.
Has anyone ever found it useful to return more than a few multiple return
values? If you knew your implementation never consed multiple return
values would you start returning hundreds or thousands of values this way?
Or would you still just pass them by reference via, e.g. an array or list?
Regards,
Adam
- Next message: Jens Axel Søgaard: "Re: A non-consing arbitrary number of multiple return values?"
- Previous message: Rob Warnock: "Re: Lisps' popularity"
- Next in thread: Jens Axel Søgaard: "Re: A non-consing arbitrary number of multiple return values?"
- Reply: Jens Axel Søgaard: "Re: A non-consing arbitrary number of multiple return values?"
- Reply: Frode Vatvedt Fjeld: "Re: A non-consing arbitrary number of multiple return values?"
- Maybe reply: Florian Weimer: "Re: A non-consing arbitrary number of multiple return values?"
- Reply: Bruno Haible: "Re: A non-consing arbitrary number of multiple return values?"
- Reply: Duane Rettig: "Re: A non-consing arbitrary number of multiple return values?"
- Maybe reply: Barry Margolin: "Re: A non-consing arbitrary number of multiple return values?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|