Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Dangling Else

Name: Anonymous 2013-06-16 13:34

Why allowing IFs missing ELSE at all? Even Scheme forbids IFs without ELSE clause. Although retarded Common Lisp allows them, despite having WHEN and UNLESS.

Name: Anonymous 2013-06-16 14:19

>>8
Rationale

The one-armed variant of if was removed from Racket to prevent bugs.

In functional code one always uses the two-armed variant of if.

(if test expr-on-true expr-on-false)

Forgetting the second arm expr-on-false would not lead to a syntax-error, but to a runtime error (the expression would return #<void>).

To prevent these often occurring bugs in functional code, it was decided to introduce the form when for the one-armed variant of if.

 (when test expr-on-true)

Besides preventing accidental bugs, the new form clearly indicated to a reader of code, that the code relies on side effects.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List