<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><br><div><blockquote type="cite"><div style="margin: 0px;"><span style="font-family: Helvetica;"><b>From: </b></span><span style="font-family: Helvetica;">Laurent <<a href="mailto:laurent.orseau@gmail.com">laurent.orseau@gmail.com</a>><br></span></div><div style="margin: 0px;"><span style="font-family: Helvetica;"><b>Subject: </b></span><span style="font-family: Helvetica;"><b>Re: [racket-dev] comments on "comments on learning Racket"</b><br></span></div><div style="margin: 0px;"><span style="font-family: Helvetica;"><b>Date: </b></span><span style="font-family: Helvetica;">April 27, 2014 at 2:39:50 AM MST<br></span></div><div style="margin: 0px;"><span style="font-family: Helvetica;"><b>To: </b></span><span style="font-family: Helvetica;">Matthias Felleisen <<a href="mailto:matthias@ccs.neu.edu">matthias@ccs.neu.edu</a>><br></span></div><div style="margin: 0px;"><span style="font-family: Helvetica;"><b>Cc: </b></span><span style="font-family: Helvetica;">"<a href="mailto:dev@racket-lang.org">dev@racket-lang.org</a> Devs" <<a href="mailto:dev@racket-lang.org">dev@racket-lang.org</a>><br></span></div><br><div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><br>On Sun, Apr 27, 2014 at 1:09 AM, Matthias Felleisen <span dir="ltr"><<a href="mailto:matthias@ccs.neu.edu" target="_blank">matthias@ccs.neu.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;">** tab completion must be faster</blockquote></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex; position: static; z-index: auto;"><br></blockquote><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;">** Do we need to add these to our library?<br><br>;; (X ... -> Y ...) X *-> [List-of Y]<br>(define (gather-return-values f . s)<br> (call-with-values (lambda () (apply f s)) list))<br><br>;; Nat (X ... -> Y ...) X *-> Y<br>(define (nth-return-value i f . s)<br> (call-with-values (lambda () (apply f s)) (lambda l (list-ref l i))))<br></blockquote><div><br></div><div>I've been having a need of these functions on several occasions myself too.<br>(Although the names are too long, but maybe just omitting `return` would be acceptable to my taste.)<br></div><div> </div></div></div></div></div></blockquote><div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><br></div></div></div></div><div>Hmmm… except for he name, I think I like that better than my own approach I wrote recently:</div><div><br></div><div>(require racket/function)</div><div><br></div><div><div>(define-syntax (values->list stx)</div><div> (syntax-case stx ()</div><div> [(_ (f args ...))</div><div> #'(call-with-values (thunk (f args ...)) list)]))</div><div><br></div><div>(define-syntax (values-ref stx)</div><div> (syntax-case stx ()</div><div> [(_ (f args ...) n)</div><div> (if (negative? (syntax->datum #'n))</div><div> (raise-argument-error 'values-ref</div><div> "exact-nonnegative-integer?"</div><div> 1</div><div> (syntax->datum #'(f args ...))</div><div> (syntax->datum #'n))</div><div> #'(let ([lst (values->list (f args ...))])</div><div> (if (<= 0 n (length lst))</div><div> (list-ref lst n)</div><div> (raise-arguments-error 'values-ref</div><div> "index too large for values list"</div><div> "index" n</div><div> "in" lst))))]))</div></div><div><br></div><div>-Kevin</div></div></body></html>