I was going to mention that common lisp has a notion of return arity, and
that certain functions can return zero results. I didn't realize that
(values) also worked in racket. Zero return arity has some nasty
consquences in existing systems. Both racket and guile barf on expressions
like (eq? (values) (values)) and like NaN results with zero arity should
probably always not be equal. Without having any idea of the actual state
of the art, I would guess that type systems can handle zero arity returns
but would guess that there may be some implementation overhead. This seems
related to the question: How do you detect that 'nothing' has happened (re:
to why do analog clocks start at 12)? Unlike nearly every other language I
have ever encountered Racket supports pretty much all of the possible
solutions, with (values), (void), and (null)/'(). In principle this means
that we can choose whichever solution works best for our use case, but
leaves open the question of how the default choice of (void) as well as the
diversity of options impacts code quality, readability, and terseness. I'm
sure someone has done a study on that but a quick search produced nothing
obvious. I also expect that some of the long time members of the community
could also provide some insight into the design decisions to include an
explicit representation of void in the language (seems to have happened
some time back in 2005). If I had to guess, having an explicit
representation makes the language more homogeneous since you aren't forced
to check whether a result has zero return values every single time but
instead can simply check whether the value returned is void (in a strict
sense it is impossible to test the equality of something with nothing, in
line with the NaN example before -- there isn't even a register with a
value in it for (values)). Would love to hear from those with more
knowledge of the history here.
Tom


On Wed, Jul 17, 2019 at 11:16 PM Sorawee Porncharoenwase <
sorawee.pw...@gmail.com> wrote:

> The other thing I'd like to see would be the option to return nothing.
>> Not #<void>, '(), or #f.  Nothing.  It's useful e.g. when you want to
>> simultaneously transform and filter a list.
>>
>
> Would (values) satisfy your criteria?
>
> #lang racket
>
> (define (my-filter-map proc xs)
>   (match xs
>     ['() '()]
>     [(cons x xs)
>      (call-with-values
>       (thunk (proc x))
>       (case-lambda
>         [() (my-filter-map proc xs)]
>         [(x) (cons x (my-filter-map proc xs))]))]))
>
> (my-filter-map (λ (x) (if (odd? x) (values) (add1 x))) '(1 2 3 4)) ;=> '(3 5)
>
> One thing I don’t like about it is that zero values (and multiple values
> in general) are really unwieldy to work with and doesn’t compose well with
> the rest of Racket. You can for example translate v >>= f in Haskell to
> just (and v (f v)) in Racket. But trying to do the same thing with zero
> values is a headache.
>
>>
>> On Wed, Jul 17, 2019 at 11:50 PM Daniel Prager <daniel.a.pra...@gmail.com>
>> wrote:
>>
>>> I'm confused on one point.
>>>
>>> Why would a new canonical notation be preferable to, say, also fully
>>> supporting an alternative general notation (like Shriram's p4p, or a
>>> derivative thereof) or even multiple notations in addition to retaining
>>> good old s-expressions?
>>>
>>> The idea would be that you could transform freely and readably between
>>> alternative notations, enabling round-tripping without degradation.
>>>
>>> I imagine that effectively providing tooling, syntax-extension, good
>>> error messages, and documentation across multiple notations would be (ahem)
>>> challenging, but so long as we're dreaming big ...
>>>
>>>
>>> Dan
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Racket Users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to racket-users+unsubscr...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/racket-users/CAFKxZVV-njHNCCLDP-RsDq%2BjbXrOGpOnaEp9Ob4ugTbdtmckAw%40mail.gmail.com
>>> <https://groups.google.com/d/msgid/racket-users/CAFKxZVV-njHNCCLDP-RsDq%2BjbXrOGpOnaEp9Ob4ugTbdtmckAw%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Racket Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to racket-users+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/racket-users/CAE8gKodKrWNeL3tJQ5uO4X64jKzBVmYY2P9BgLsd%3Dqh8bhSQyw%40mail.gmail.com
>> <https://groups.google.com/d/msgid/racket-users/CAE8gKodKrWNeL3tJQ5uO4X64jKzBVmYY2P9BgLsd%3Dqh8bhSQyw%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/CADcueguTp19B7Yqb9nZM%3DJfiofWU4-JBdC-aaoFXq4vthUe3NQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/racket-users/CADcueguTp19B7Yqb9nZM%3DJfiofWU4-JBdC-aaoFXq4vthUe3NQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CA%2BG3_PM02qeGKKN6xWM_TTyxRcVxYDL%3Ddnh_fRSiis2ZPtpXnQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to