Evaluation Order EvaluationStrategies nat11.png https://docs.google.com/a/brown.edu/forms/d/e/1FAIpQLSc3SyZV5N6ZWXjxK1C-r5ErHVRweP32kErkvgWoBf-vpeQNlg/viewform core1 core2 core3 extra1 Nil nil

The sole value of the Nil type. `nil` is frequently used to represent the absence of a value.

Let let <name> = <expr>; ...

Evaluates `expr`, and binds the result to `name`.

Parentheses (<expr>)

Parentheses are used for grouping expressions. They do not otherwise change the meaning of the program.

Number Literals 9000.1 -42 9.0001e+3

Evaluation of a number literal yields a numeric value. Integer, decimal, and scientific notation is supported.

Binary Arithmetic Operations <expr> + <expr> <expr> - <expr> <expr> * <expr> <expr> / <expr>

These arithmetic operations raise exceptions if their arguments do not evaluate to numbers. Otherwise, they perform the specified operation.

Booleans true false

The true and false values of the boolean type.

String Literals "I am a string."

Evaluation of a string literal yields a string value. String values hold ordered sequences of characters. They are usually used as representations of human readable text.

String Concatenation <expr> ++ <expr>

Appends two strings together. This does not modify the strings, but instead produces a new string.

Comparisons <expr> < <expr> <expr> > <expr> <expr> <= <expr> <expr> >= <expr> <expr> == <expr> <expr> != <expr>

These operations perform the specified comparison, returning a boolean. Only numbers can be compared.

Conditionals if <condition> { <then_branch> } else { <else_branch> }

Evaluates the `condition`, followed by either the `then_branch` or the `else_branch`, depending on its result.

Function Declaration func <name>(<param>, ...) { <expr> }; ...

Evaluating a function statement produces a function value and binds it to `name`. The function definition does not evaluate the function body; this happens when the function is called.

Function Application <expr>(<expr>, ...)

Applies a function to zero or more arguments.

Assignment Statement <name> := <expr>; ...

Evaluates `expr`, and changes the value bound to `name`.

Lambda Expression lambda(<param>, ...) { <expr> }

Produces a first-class function value. It can be applied the same way as named functions.

Record Literal { <expr>: <expr>, ... }

On the left of each colon is a field name, and on the right is its definition. This syntax constructs a record where each field name is associated with its corresponding definition.

Field access <expr>[<expr>]

Evaluates the first expression to a record value and the second expression to a field name, then looks up that field name in that record.

Field assignment <expr>[<expr>] := <expr>; ...

The first expression is the record, the second is the field name, and the third is the new value. This syntax changes the record by setting the given field name to the new value.

For instance,

```let record = {"x": 1};
record["x"] := 2;
record["x"]
```

will produce `2`.

Evaluation Order Focus on function application. The code has become sentient, and refuses to tell us what it does.