Re: returning multiple values vs a list
From: Paul F. Dietz (dietz_at_dls.net)
Date: 10/28/04
- Next message: surendra: "lisp problem"
- Previous message: Hartmann Schaffer: "Re: OT Reptitive Strain Injury"
- In reply to: Peter Seibel: "returning multiple values vs a list"
- Next in thread: Peter Seibel: "Re: returning multiple values vs a list"
- Reply: Peter Seibel: "Re: returning multiple values vs a list"
- Reply: Adam Warner: "Re: returning multiple values vs a list"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 27 Oct 2004 20:39:03 -0500 To: Peter Seibel <peter@javamonkey.com>
Peter Seibel wrote:
> Suppose I'm writing a function to take apart a list into a few pieces.
> I can write it to return multiple values and let callers use
> MULTIPLE-VALUE-BIND to grab the individual parts. Or I can write it to
> return a list and let callers use DESTRUCTURING-BIND. Any reason to
> prefer one or the other? Suppose for the sake of argument that
> everywhere I use it I use all the values; obviously if I sometimes
> wanted only the primary value then multiple values would be the way to
> go.
Multiple values can be implemented without heap allocation;
that's harder to do for a list.
Another thing you could do is allocate a simple vector in the caller,
pass the simple vector to the function, and have the function fill in
the vector. If the vector is declared dynamic extent it can be heap
allocated. Wrap with suitable macros to hide the details.
Paul
- Next message: surendra: "lisp problem"
- Previous message: Hartmann Schaffer: "Re: OT Reptitive Strain Injury"
- In reply to: Peter Seibel: "returning multiple values vs a list"
- Next in thread: Peter Seibel: "Re: returning multiple values vs a list"
- Reply: Peter Seibel: "Re: returning multiple values vs a list"
- Reply: Adam Warner: "Re: returning multiple values vs a list"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|