18 Record Syntax and Semantics

Record syntax

Record semantics

Evaluation:

Type checking:

Record copy

{e with f1 = e1} will create a copy of record e with field f1 set to e1.

Note that this created a new record, it's immutable, as always.

In reality, record copy is syntactic sugar for just rewriting the record from scratch. It's much easier to change fields like this. Note that you can't add more fields, because that would change the type: