<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"><base></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><br><div><div>On Nov 24, 2014, at 8:49 AM, Roman Klochkov <<a href="mailto:kalimehtar@mail.ru">kalimehtar@mail.ru</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">Like this?<br><br>(and <br>    (> y 0)<br>    (set! x (> y 3))<br>    (set! y (- y 1)))<br><br>I thought, that (when ...) should be used in such case.<span class="Apple-converted-space"> </span><br>(and ..) instead will be rather confusing (for example, Common Lispers expect, that (set! x #f) is #f).<br></div></blockquote><div><br></div><div>Well since in racket it returns void which is a truthy value, in racket you can use and just like begin except that if one of the expressions returns #f it stops.  Also you can use (or (and condition then-expr ...) …) as a kind of variant of cond that uses #f to signal a fall-through to the next “clause”.</div><div>I find these kinds of things pretty convenient and intuitive, once I got used to void being a truthy value and and and or returning non-boolean answers.  </div><div><br></div><div>And also, there won’t be a lot of situations where the context expects zero values, and for the one you showed, you can do this:</div><div>(define-syntax-rule (local-phase-1 expr …)</div><div>  (define-synatxes ()</div><div>    (let () expr ... (values))))</div><div><br></div><div>And if you want to use it within something like (let-syntaxes ([() (something)]) …),</div><div>(define-simple-macro (my-let-syntaxes (binding …) body:expr …+)</div><div>  #:with (new-binding …)</div><div>  (for/list ([binding (in-list (syntax->list #’(binding …)))])</div><div>    (syntax-parse binding</div><div>      [[(id …) expr …] #’[(id …) (let () expr …)]]</div><div>      [[(~literal _) expr …] #’[() (let () expr … (values))]]))</div><div>  #’(let-syntaxes (new-binding …) body …))</div><br><blockquote type="cite"><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br><br>Sun, 23 Nov 2014 22:47:23 -0500 от "Alexander D. Knauth" <<a href="mailto:alexander@knauth.org">alexander@knauth.org</a>>:<br><blockquote style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(8, 87, 166); margin: 10px; padding: 0px 0px 0px 10px;"><div id=""><div class="js-helper js-readmsg-msg"><base target="_self" href="https://e.mail.ru/"><div id="style_14168008530000000877_BODY"><div>Most contexts expect one value, and you can easily define a macro that does the</div><div>(define-syntaxes ()</div><div>  (begin0 (values) expr …))</div><div>or</div><div>(define-syntaxes ()</div><div>  (begin expr … (values)))</div><div>for you.  </div><div><br></div><div>The one that comes too my mind first is</div><div>(and (test-something-about x) (do-something-with x) (do-something-else-with x)),</div><div>where (do-something-with x) just returns void (which is a truthy value), but only if the test is true.  </div><br><div><div>On Nov 23, 2014, at 9:17 PM, Roman Klochkov <<a href="x-msg://e.mail.ru/compose/?mailto=mailto%3akalimehtar@mail.ru" target="_blank">kalimehtar@mail.ru</a>> wrote:</div><br><blockquote type="cite"><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">I can't imagine an example, where one need to use void function in context, that expects a single value.<br>Moreover, in macro definition I had to write<br><br><p>(define-syntaxes ()<br>   (begin0 (values)<span> </span><br>                  (save-fields! #'NAME (list 'ALL-FIELD ...))<br><br>to make side effect work in expansion time. I cannot write simply (save-fields! #'NAME (list 'ALL-FIELD ...), because save-fields! is at phase-1.<br>I prefer to write simply </p>(define-syntaxes ()  (save-fields! #'NAME (list 'ALL-FIELD ...))<br><br>but then save-fields! should return no values, not one void value.<br><br>Can you bring an example, where one have to to use void function in a context that expects a single value?<br><br><br>Sun, 23 Nov 2014 18:21:47 -0500 от "Alexander D. Knauth" <<a href="x-msg://e.mail.ru/compose/?mailto=mailto%3aalexander@knauth.org" target="_blank">alexander@knauth.org</a>>:<br><blockquote style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(8, 87, 166); margin: 10px; padding: 0px 0px 0px 10px;"><br><div><div>On Nov 23, 2014, at 1:31 PM, Roman Klochkov <<a target="_blank"></a><a href="mailto:kalimehtar@mail.ru">kalimehtar@mail.ru</a>> wrote:</div><br><blockquote type="cite"><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">> void is a good placeholder in dummy functions/objects<br><br>(define (foo) (values)) also works just fine.<br></div></blockquote><div><br></div><div>But then you can’t use (foo) in a context that expects a single value, but if you use (void) instead of (values), it will return one value (instead of zero values), and so you can use it in contexts that expect one value.  </div><br><blockquote type="cite"><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br>> fill a gap, which is useful<br><br>If function returns void?, then it is used as a procedure. I mean returned value never assigned to a variable.<br>So in what cases it is useful?<br><br><br>Sun, 23 Nov 2014 13:20:26 +0000 от Stephen De Gabrielle <<a target="_blank"></a><a href="mailto:spdegabrielle@gmail.com">spdegabrielle@gmail.com</a>>:<br><blockquote style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(8, 87, 166); margin: 10px; padding: 0px 0px 0px 10px;">void is a good placeholder in dummy functions/objects. It doesn't do anything, except for fill a gap, which is useful.<br><br>Values is used to pass multiple values.<span> </span><br><br>Check the manual for details.<br><br>Does that help?<br><br>Stephen<br><br><div>On Sun, 23 Nov 2014 at 12:56 Roman Klochkov <<a target="_blank"></a><a href="x-msg://e.mail.ru/compose/?mailto=mailto%3akalimehtar@mail.ru" target="_blank">kalimehtar@mail.ru</a>> wrote:<br><blockquote style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;"><div>When I should use (void) and when (values)?<br><br>They are both used to show, that there are no return values.<br>They are both not printable.<br><br>What is intended use for (void) and (values) and when one should prefer one over other?<br><br>--<span> </span><br>Roman Klochkov</div>____________________<br>  Racket Users list:<br> <span> </span><a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/<u></u>users</a><br></blockquote></div></blockquote><br><br>--<span> </span><br>Roman Klochkov<br>____________________<br> Racket Users list:<br> <a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/users</a></div></blockquote></div><br></blockquote><br><br>--<span> </span><br>Roman Klochkov</div></blockquote></div><br></div><base target="_self" href="https://e.mail.ru/"></div></div></blockquote><br><br>--<span class="Apple-converted-space"> </span><br>Roman Klochkov</div></blockquote></div><br></body></html>