Skip to content

Choices

The evaluator of if shows why an evaluator gets its parts sealed and not evaluated. It evaluates the test first. Then it evaluates only the branch that the test selects. The other branch is not evaluated, and its card says so.

The glyphs so far: 12, 1 new on this page
  • 42Data: a value without a type
  • number
    42
    A document: the tab is its type
  • number
    42
    A dashed tab: the container declares the type
  • add
    number
    1
    number
    2
    Parts: a card inside a card
  • kindA kind: a document of type kind
  • OKDA rung: own, kind or default
  • 3A port: the result of a document
  • 0A sealed part: an evaluator cannot read it
  • #NAME?An error value, in a red port
  • numbera
    3
    A name tag: a binding for later steps
  • ref
    namesa
    A reference: a path from a root of the context
  • if
    test
    bool
    true
    true
    then
    text
    “yes”
    “yes”
    else
    text
    “no”
    not evaluated
    “yes”
    Not evaluated: a part that its parent did not neednew

The context has the name size with the value 12. Thus the test is true, and the log in the other branch does not happen.

Open in the playground

The evaluation of if ends with "big".

if
test
greater
ref
namessize
12
number
10
10
true
then
text
“big”
“big”
else
▸log
text
“small”
not evaluated
not evaluated
“big”
The result of the document: “big”
The test gives true. The evaluator of if evaluates then, and it does not evaluate else. No log happens.

With the size 4, the test is false. The evaluator evaluates the branch else, and the log happens.

Open in the playground

The evaluation of if ends with "small".

if
test
greater
ref
namessize
4
number
10
10
false
then
text
“big”
not evaluated
else
▸log
text
“small”
“small”
“small”
“small”
The world: the effects, in order
  1. 1log“small”
The result of the document: “small”
The test gives false. The evaluator of if evaluates else, and the log happens. The branch then is not evaluated.

A condition is not a special part of the language. It is a kind with an evaluator, as add is. Any evaluator can decide which parts to evaluate, how many times, and in which context. A loop, a retry and a handler that waits for an event are evaluators of the same form.