Reference#
- aif Macro#
- Macro Call:
aif(*expression*) body [;] [else body [;] ] end;
- Discussion:
Sometimes, in a program, we want to test if an expression returns a value or is
#f
, and if so, to do something with the value. If the expression is costly to evaluate, then we must do something like this:let result = big-long-calculation(); if (result) foo(result) end;
But with
aif
we could say:aif(big-long-calculation()) foo(it) end;
or
aif(big-long-calculation()) foo(it) else bar() end;