Part 3: Special Forms, expr with thunks
Logical special forms include if
, and
, or
, and cond
. These expressions are special because not all of their sub-expressions may be evaluated.
In Scheme, only #f
is a false value. All other values (including 0
and nil
) are true values. You can test whether a value is a true or false value using the provided Python functions is_scheme_true
and is_scheme_false
, defined in scheme_builtins.py
.
Scheme traditionally uses
#f
to indicate the false Boolean value. In our interpreter, that is equivalent tofalse
orFalse
. Similarly,true
,True
, and#t
are all equivalent. However when unlocking tests, use#t
and#f
.
To get you started, we've provided an implementation of the if
special form in the do_if_form
function. Make sure you understand that implementation before starting the following questions.