[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: when and unless
From: |
Marijn |
Subject: |
Re: when and unless |
Date: |
Tue, 06 Dec 2011 08:48:01 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:8.0) Gecko/20111117 Thunderbird/8.0 |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi Andy,
On 05-12-11 21:23, Andy Wingo wrote:
> Heya Ludo,
>
> On Thu 30 Jun 2011 12:44, Andy Wingo <address@hidden> writes:
>
>> I think we should add `when' and `unless' to the default
>> environment.
>>
>> They go like this:
>>
>> (define-syntax when (syntax-rules () ((_ test then then* ...) (if
>> test (begin then then* ... (if #f #f))))))
>>
>> (define-syntax unless (syntax-rules () ((_ test else else* ...)
>> (if (not test) (begin else else* ... (if #f #f))))))
>
> WDYT? `unless' is nice for assertions, `when' is its converse, and
> most Schemes have them. I would like to add them to Guile too.
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?
Marijn
[1]:http://clhs.lisp.se/Body/m_when_.htm
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.18 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAk7dyLEACgkQp/VmCx0OL2yAQACeL8y4js+HOZn1IBqFEJEl8n3I
i+MAn0TBdz2e1lP9n2EyP9PDlM7ATKUL
=nrWC
-----END PGP SIGNATURE-----
- Re: when and unless, Andy Wingo, 2011/12/05
- Re: when and unless,
Marijn <=
- Re: when and unless, Alex Shinn, 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, 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