View Source Document

if.robin

;'<<SPEC'

<!--
Copyright (c) 2012-2024, Chris Pressey, Cat's Eye Technologies.
This file is distributed under a 2-clause BSD license.  See LICENSES/ dir.
SPDX-License-Identifier: LicenseRef-BSD-2-Clause-X-Robin
-->

### `if` ###

    -> Tests for functionality "Evaluate core Robin Expression"

`if` evaluates its first argument to a boolean value.  If that value is
`#t`, it evaluates, and evaluates to, its second argument; or if that value
is `#f` it evaluates, and evaluates to, its third argument.  In all cases,
at most two arguments are evaluated.

    | (if #t 7 9)
    = 7

    | (if #f 7 9)
    = 9

The identifiers named in the branch which is not evaluated need not be
properly bound to values in the environment.

    | (if #t 1 (prepend fred ethel))
    = 1

The second and third arguments can be arbitrary expressions, but `if`
expects its first argument to be a boolean.

    | (if 5 7 9)
    ? abort (expected-boolean 5)

`if` expects exactly three arguments.

    | (if #t 7)
    ? abort (illegal-arguments (#t 7))

    | (if #t 7 8 9)
    ? abort (illegal-arguments (#t 7 8 9))

`if` is basically equivalent to Scheme's `if`.

'<<SPEC'

(require if)