Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!snorkelwacker.mit.edu!ai-lab!ai.mit.edu!tmb From: tmb@ai.mit.edu (Thomas M. Breuel) Newsgroups: comp.lang.scheme Subject: Re: Multiple return values Message-ID: <14592@life.ai.mit.edu> Date: 3 Apr 91 11:22:35 GMT References: <1991Apr1.181633.12561@snitor.uucp> <9104022333.AA00572@cymbal.reasoning.com.> Sender: news@ai.mit.edu Reply-To: tmb@ai.mit.edu Organization: MIT Artificial Intelligence Lab Lines: 47 In article <9104022333.AA00572@cymbal.reasoning.com.>, gyro@cymbal.reasoning.COM (Scott Layson Burson) writes: |> |> Date: Mon, 1 Apr 1991 18:16:33 GMT |> From: Doug Moen |> |> In the latest issue of LISP Pointers, Pavel Curtis (Pavel@Xerox.Com) |> discusses the Scheme multiple return value proposal. |> [...] |> |> I have a counter-proposal. I feel there is a much simpler way to |> support multiple return values; one which fits in better with the |> rest of the language: multiple return values are represented by lists. |> [...] |> |> I like to write in a style that makes liberal use of multiple values. I |> would be discouraged from doing so on efficiency considerations were |> they to be implemented as lists. I think it is wrong to add multiple return values to Scheme for efficiency reasons: the gain in efficiency is small to non-existent for good compilers, and the semantics are messy. In order to gain efficiency through the use of a special multiple return values data type, you have to seriously restrict how you can manipulate multiple return values (if you treat a set of multiple return values as a first class object, you might as well use lists, since the Scheme optimizer would face exactly the same problems in compiling this new data type efficiently). This adds lots of semantic hair to the language. And, the gains in execution speed are dubious at best. In fact, I suspect that since modern Scheme implementations have done away with the stack altogether and allocate all procedure activation frames on the heap, data structures representing multiple return values would simply end up on the heap as well. Also, in those cases where multiple return values could be allocated in a stack-like manner, a Scheme compiler stands a pretty good chance to eliminate heap allocation even when they are implemented using lists. A nice addition to Scheme that would make the use of lists as multiple return values a little more convenient would be some form of destructuring. I doubt that the Scheme committee as a whole could agree on destructuring binding for argument lists (which I would prefer), but a special form DESTRUCTURING-BIND or DLET would certainly be nice. Thomas.