evaluation - pannous/warp GitHub Wiki
Evaluation turns code into values. A program is code and is evaluated; a data file is data and is not. When
each part of a program is evaluated (values now, charged code at every use, uncharged blocks only with !), and
the vocabulary, are specified in charged.
- Call arguments are evaluated before the call, except for parameters declared
block. ( … )groups are evaluated on the spot;{ … }is data or a block by default;[ … ]lists evaluate their elements.x!runs a block once,x!!fully (full-evaluation);do xisx!(do).- The compiler computes pure parts as early as it can (constant folding, hoisting, memoization; compiler-only, no user memoization syntax); this never changes what a program observes (charged section 3). Effects such as State and Eval block that path (effects).
- The shell can keep assignments symbolic and show the evaluation step by step.
Related keywords: result (the last value), it (the implicit argument).
calling a function value
A closure is called by giving it a group on the right: ((x -> x * 2) 7) is 14. Since a group of one
element is the element itself, (x) == x, there is an ambiguity if the parentheses are omitted.