chicken-users
[Top][All Lists]
Advanced

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

Re: [Chicken-users] Correct behavior of SRFI-1 any


From: Alaric Snell-Pym
Subject: Re: [Chicken-users] Correct behavior of SRFI-1 any
Date: Tue, 29 Nov 2011 12:27:37 +0000
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.18) Gecko/20110617 Thunderbird/3.1.11

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 11/29/2011 12:23 PM, Christian Kellermann wrote:

> Actually the result of the else branch of (if (even? x) x) is
> undefined.

Aye. A single-armed "if" is only really useful for conditionalising code
performed for its side effects, as the return value of such an if is
useless.

Because this can be confusing, it's recommended to use "when" for
side-effecting conditionals, which has the added advantage of the body
being arbitrarily long, as there's no need to use position to
distinguish yay and nay branches:

(when (...some test...)
         (...do something...)
         (...do something...)
         (...do something...))

Indeed, a single-armed "if", especially used in a context where the
result is checked (eg, a non-final element of a BEGIN), is potentially
grounds for a compiler warning...

ABS

- --
Alaric Snell-Pym
http://www.snell-pym.org.uk/alaric/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk7Uz7kACgkQRgz/WHNxCGqVZACgjO+Alqkm/D7F4o7sEeuS0W0R
1BMAnRG6s2CjV+x0sHW8EjEhLmAS15d8
=3u1p
-----END PGP SIGNATURE-----



reply via email to

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