<div dir="ltr"><br><div class="gmail_extra">Matthias, <br></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jul 12, 2013 at 7:36 PM, Greg Hendershott <span dir="ltr"><<a href="mailto:greghendershott@gmail.com" target="_blank">greghendershott@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div>>> Then why not return lists instead of values?<br>
> Error checking.<br></div></blockquote><div><br></div><div>Well, expecting a number and receiving a list (instead of several values) is not very different from expecting a number and receiving a string.<br>In both cases the user didn't read the specs correctly.<br>
</div><div>But sure, the more checks we can have, the better.<br></div><div>
<br></div><div>I suspect it has more to do with optimization (once again), than error checking.<br><br>> See Dybvig's paper,<br><br>Thanks for the reference, this is very informative and well written.<br></div><div>
The performance checks seem to be quite tailored toward `values', and there are cases where what you really need to do is to handle the returned values as a list.<br></div><div>I read it quickly (for that first time) but the "error handling" part does not seem to be the main reason.<br>
<br></div><div>Greg,<br>
</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div>
</div>Although nowadays we have match-define and friends.<br>
<br>
(define-values (a b c) (return-3-values))<br>
(match-define (list a b c) (return-3-element-list))<br>
<br>
Both would error appropriately.<br></blockquote><div><br>Probably those cases are not the ones with problems.<br></div></div><br>I guess one of the worst cases would be if you call:<br>
</div><div class="gmail_extra">(foo (bar 3))<br></div><div class="gmail_extra">where (bar 3) returns a list, but at some point its implementation changes and returns both a list and a string, encapsulated as multiple values in a list.<br>
Then foo will not error correctly and it may be non-trivial to find the bug.<br></div><div class="gmail_extra">But of course this is a backward-incompatible change so that's the kind of problem you can expect from such a change.<br>
<br></div><div class="gmail_extra">A related problem is if you misread the docs and consider that `bar' returns `(list 3 3 3)' whereas it actually returns multiple values `(list "something" (list 3 3 3))'.<br>
<br></div><div class="gmail_extra">An intermediate solution would be that `values' returns indeed a `list', but (somehow) tagged with 'values, so that one can now it's suppose to mean a multiple return value but can still be handled with all the tools from `list'.<br>
</div><div class="gmail_extra"><br></div><div class="gmail_extra">Thanks to all other repliers for their interesting comments.<br><br></div><div class="gmail_extra">Laurent<br></div><div class="gmail_extra"><div class="gmail_quote">
<div class="gmail_extra"><br></div></div></div></div>