Alex Shinn <alexsh...@gmail.com> writes:

> On Tue, Dec 6, 2011 at 4:48 PM, Marijn <hk...@gentoo.org> 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