Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Purple Session Bindings

The boot installs fourteen bindings into the session environment before the prelude loads — the Pink machinery of Part III, made available at the prompt. They fall into four groups.

Sources

Programs as data, exactly as read or spliced at boot:

  • pink-poly-src — the contents of lib/pink-forms.naj: the stage-polymorphic evaluator as one expression.
  • pink-tie-srcpink-poly-src wrapped with the knot-tying lambda; takes an l pair.
  • pink-eval-srcpink-tie-src applied to the identity lift, as source.
  • pink-evalc-srcpink-tie-src applied to the real lift, as source.
(car pink-poly-src)
;=> 'let

Evaluators

The same four, animated:

  • pink-poly — the evaluator awaiting its own recursion (tie).
  • pink-tie — the knot tied; takes an l pair, gives an evaluator.
  • pink-eval((pink-eval src) env) interprets src.
  • pink-evalc — the compiling reading; applications of it must be enclosed by the run that scopes their generated code (the Futamura chapter’s discipline).
((pink-eval '(car '(a b))) nil-env)
;=> 'a

Futamura artifacts

Compiled at every boot:

  • compilerpink-eval compiled by pink-evalc (the second projection): an evaluator with the interpretive overhead removed, used exactly like pink-eval.
  • evalc-compiledpink-evalc compiled by itself (the third projection): the compiler as a compiled artifact.
((compiler '(+ 1 2)) nil-env)
;=> 3

Helpers

  • nil-env — the empty Pink environment, (lambda _ y 0): every lookup answers 0.
  • ((interpret src) env)pink-eval, spelled as a verb.
  • (compile src)(run 0 ((evalc-compiled src) nil-env)): compile a closed program and execute the residual, all inside one run scope.
  • (run-compiled anf)(run 0 anf) for code compiled within the same scope; code generated loose at the prompt dangles, per the Futamura chapter.
((interpret '(+ 1 2)) nil-env)
;=> 3
(compile '(* 6 7))
;=> 42

The prelude’s five functions (previous chapter) arrive on top of these, and load/define are loop forms, not bindings. Two more names exist in lib/purple.naj but are boot-internal, not installed: load-into, a Pink-path loader that folds a file’s define forms into an environment-as-function, and tower-load, the loader behind the loop’s load.