Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!usc!snorkelwacker.mit.edu!ai-lab!zurich.ai.mit.edu!jinx From: jinx@zurich.ai.mit.edu (Guillermo J. Rozas) Newsgroups: comp.lang.scheme Subject: Re: Multiple return values Message-ID: Date: 3 Apr 91 21:01:50 GMT References: <1991Mar26.155905.12906@daffy.cs.wisc.edu> <1991Apr1.181633.12561@snitor.uucp> Sender: news@ai.mit.edu Reply-To: jinx@zurich.ai.mit.edu Organization: M.I.T. Artificial Intelligence Lab. Lines: 86 In-reply-to: carlton@husc10.harvard.edu's message of 3 Apr 91 03:25:54 GMT There are a lot of issues in multiple values that haven't been mentioned. I like to classify them by code. Here are some of the more controversial points. A: Are the following two expressions equivalent? (values 1) 1 B: Is the following expression legal? (begin (values 1 2 3) 4) C: Is the following expression legal? (begin (values) 4) D: Is the following expression legal, and, if so, what does it return? (let ((x (values 1 2))) x) E: Is the following expression legal, and, if so, what does it return? (let ((x (values))) x) F: Is the following expression legal? (call-with-values (lambda () (values 1 2 3)) (lambda (x y) (list x y))) G: Is the following expression legal, and, if so, what does it return? (call-with-values (lambda () (values 1)) (lambda (x y) (list x y))) H: Does the following work? (call-with-values (lambda () (call-with-current-continuation (lambda (k) (k 1 2)))) (lambda (x y) (list x y))) PS: - By equivalent I mean that either can be substituted for the other without changing the meaning of the program (ignoring capture of free variables). - By legal I mean it is not in error. - By work I mean it is legal and the "obvious" value(s) is(are) returned. My preferences are: A: Yes. B: Yes. C: Yes. D: Yes, 1. E: No. F: No. G: No. H: Yes. But would accept a compromise where any of the above are left unspecified. My arm would need a lot of twisting to accept a proposal that requires any of those decisions to be otherwise. Although this set of choices may appear inconsistent, the crucial observation, that points out the asymmetry between APPLY and VALUES is that there are no implicit procedures, but there are implicit continuations. Furthermore, the continuation that VALUES is invoking is not apparent in the VALUES expression, but the (expression evaluating to) the procedure in APPLY expressions is. Given these asymmetries, the decisions need not be the same.