[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: when and unless

From: David Kastrup
Subject: Re: when and unless
Date: Tue, 06 Dec 2011 12:17:06 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.90 (gnu/linux)

Alex Shinn <address@hidden> writes:

> 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.

I've actually wondered if it would not make sense to return
*unspecified* in the case of the plain else-less if even if the
condition is true, namely when you write (if #t #t).

There is probably code relying on this to be #t, but frankly, this
appears like a recipe for breakage.

David Kastrup

reply via email to

[Prev in Thread] Current Thread [Next in Thread]