File: when

package info (click to toggle)
scheme9 2025.08.12-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,080 kB
  • sloc: lisp: 16,752; ansic: 11,869; sh: 806; makefile: 237; sed: 6
file content (18 lines) | stat: -rw-r--r-- 740 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
S9 LIB  (unless <test-expression> <body>)  ==>  object
        (when <test-expression> <body>)    ==>  object

        (load-from-library "when.scm")

The WHEN syntax first evaluates <test-expression>. When it evaluates
to a true value, it also evaluates <body>, which is a sequence of
expressions. The expressions will be evaluated in order and the value
of the last expression will be returned. When <test-expression>
evaluates to #f, WHEN does not evaluate its <body> and returns an
unspecific value.

UNLESS is evaluates its body only if <test-expression> evaluates to #F.
It evaluates its <body> exactly if WHEN would not evaluate it and vice
versa.

(when (= 1 1) 'foo 'bar 'baz)    ==>  baz
(unless (= 1 2) 'foo 'bar 'baz)  ==>  baz