-
Notifications
You must be signed in to change notification settings - Fork 11
Uri edited this page Oct 6, 2021
·
4 revisions
Ol provides extended syntax for if
statement.
This is classic R7RS if
statement:
(if <expression> <then-clause>)
(if <expression> (begin <then1-clause> .. <thenN-clause>))
(if <expression> <then-clause> <else-clause>)
(if <expression> <then-clause> (begin <else1-clause> .. <elseN-clause>))
(if <expression> (begin <then1-clause> .. <thenN-clause>) (begin <else1-clause> .. <elseN-clause>))
Ol provides special words then
and else
and extends if
statement as:
(if <expression> then <then-clause>)
(if <expression> then <then1-clause> .. <thenN-clause>)
(if <expression> <then-clause> else <else-clause>)
(if <expression> <then-clause> else <else1-clause> .. <elseN-clause>)
(if <expression> then <then-clause> else <else-clause>)
(if <expression> then <then-clause> else <else1-clause> .. <elseN-clause>)
(if <expression> then <then1-clause> .. <thenN-clause> else <else-clause>)
(if <expression> then <then1-clause> .. <thenN-clause> else <else1-clause> .. <elseN-clause>)
As you can see no more begin
is required if you use then
or else
. Your code is now became more human readable:
(if some-expression
then please-do-something
and-do-more-something
else do-something-more)