On Wed, Apr 11, 2012 at 2:42 PM, lothar atheling <loth...@warpmail.net> wrote: > > usually an (if ...) form without an else part does not cause an error. > > but sometimes it does, as the following shows: > > > if: bad syntax (must have an "else" expression) in: (if isinitialised > (expose)) > > why the different behavior?
The main Racket language changed to force 'if' to make the consequent and alternative both mandatory, motivated by a desire to reduce the chance of bugs. Here's a link to some of the discussion back in 2009: http://lists.racket-lang.org/users/archive/2009-September/035423.html If you do really need one-armed ifs, consider using "when" and "unless" instead. Using 'when' and 'less' makes it clear to readers that it's intentional that a conditional branch doesn't fire off when the test fails. By the way, it is possible for you to personally weaken the restriction on 'if', since Racket's syntax permits overriding the language's default. But see if using 'when' and 'unless' is sufficient for your programs first. ____________________ Racket Users list: http://lists.racket-lang.org/users