[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: when and unless
From: |
Alex Shinn |
Subject: |
Re: when and unless |
Date: |
Tue, 6 Dec 2011 17:29:30 +0900 |
On Tue, Dec 6, 2011 at 4:48 PM, Marijn <address@hidden> wrote:
>
> Couldn't help but wonder why they don't return the value of the last
> body form, so I looked around a bit and both CLHS[1] and my racket
> REPL seem to agree that they should:
>
> $ racket
> Welcome to Racket v5.2.0.4.
>> (when #t 'hello)
> 'hello
>> (unless #f 'hi)
> 'hi
>
> Is there some other source that suggests that the return value should
> be unspecified?
Because the result is meaningless when the condition is false.
CLHS returns nil in this case, but that fits with CL idioms and
not Scheme idioms. when and unless are for side-effects - it's
better to write (and #t 'hello) if you want the result.
R7RS also leaves it unspecified.
--
Alex
- Re: when and unless, Andy Wingo, 2011/12/05
- Re: when and unless, Marijn, 2011/12/06
- Re: when and unless,
Alex Shinn <=
- Re: when and unless, David Kastrup, 2011/12/06
- Re: when and unless, Andy Wingo, 2011/12/06
- Re: when and unless, David Kastrup, 2011/12/06
- Re: when and unless, Andy Wingo, 2011/12/06
- Re: when and unless, David Kastrup, 2011/12/06
- Re: when and unless, Chris K. Jester-Young, 2011/12/06
- Re: when and unless, David Kastrup, 2011/12/07
- Re: when and unless, Chris K. Jester-Young, 2011/12/07
- Re: when and unless, David Kastrup, 2011/12/08
- Re: when and unless, Chris K. Jester-Young, 2011/12/08