Skip to content

Names

A sequence evaluates its steps in their written order. A step with a name tag gives its result to the later steps under that name. A reference reads a name back. This is the scope of let*: each binding sees the bindings before it.

The glyphs so far: 11, 2 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 stepsnew
  • ref
    namesa
    A reference: a path from a root of the contextnew
Open in the playground

Nothing started yet. Select Next or Play.

seq
  1. 1
    adda
    number
    1
    number
    2
  2. 2
    multiplyb
    ref
    namesa
    number
    10
  3. 3
    ▸log
    ref
    namesb
The world: the effects, in orderNo effect yet.
The result shows at the end of the evaluation.
Step 1 gives a. Step 2 reads a, and gives b. Step 3 reads b and logs it. Select each step, and look at its names in the panel.

Select the steps one after the other, and look at the panel. Step 1 can read no name. Step 2 can read a. Step 3 can read a and b. The sequence makes the context larger after each named step. A reference to a later name gives #NAME?, because that name does not exist yet.

Open in the playground

The evaluation of seq ends with the error #VALUE!: The value of ref is a path: a list that starts with a root, for example ["names", "a"].

seq
  1. 1
    ref
    no path
    #VALUE!
  2. 2
    numberlater
    1
    not evaluated
#VALUE!
The result of the document: #VALUE!
Step 1 reads later, and step 2 gives later. The name does not exist when step 1 starts, thus the result is #NAME?.

A name and a nesting are two forms of one thing

Section titled “A name and a nesting are two forms of one thing”

A sequence with names is the same as nested bindings: let a = 1 + 2 in let b = a * 10 in log b. The sequence writes the nesting as a list, so that a person reads it from the top to the bottom.