[racket] (values) vs (void)

From: Alexander D. Knauth (alexander at knauth.org)
Date: Sun Nov 23 18:21:47 EST 2014

On Nov 23, 2014, at 1:31 PM, Roman Klochkov <kalimehtar at mail.ru> wrote:

> > void is a good placeholder in dummy functions/objects
> 
> (define (foo) (values)) also works just fine.

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.  

> 
> > fill a gap, which is useful
> 
> If function returns void?, then it is used as a procedure. I mean returned value never assigned to a variable.
> So in what cases it is useful?
> 
> 
> Sun, 23 Nov 2014 13:20:26 +0000 от Stephen De Gabrielle <spdegabrielle at gmail.com>:
> void is a good placeholder in dummy functions/objects. It doesn't do anything, except for fill a gap, which is useful.
> 
> Values is used to pass multiple values. 
> 
> Check the manual for details.
> 
> Does that help?
> 
> Stephen
> 
> On Sun, 23 Nov 2014 at 12:56 Roman Klochkov <kalimehtar at mail.ru> wrote:
> When I should use (void) and when (values)?
> 
> They are both used to show, that there are no return values.
> They are both not printable.
> 
> What is intended use for (void) and (values) and when one should prefer one over other?
> 
> -- 
> Roman Klochkov
> ____________________
>   Racket Users list:
>   http://lists.racket-lang.org/users
> 
> 
> -- 
> Roman Klochkov
> ____________________
>  Racket Users list:
>  http://lists.racket-lang.org/users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20141123/5a9e1eb2/attachment.html>

Posted on the users mailing list.