SML: A Pure Functional Language
Programs are expressions; values are immutable
Standard ML (SML) is a pure functional programming language. Per Def 1.1 (slides p.197), a language is functional if every procedure can be fully described by its input/output behavior — no hidden state, no mutable memory.
Three ideas make SML different from languages you may have seen:
- Programs are expressions. A program is a syntactic expression that the interpreter evaluates to a value. There are no statements that just "do" something without returning a result.
- Values are immutable. Once a variable is bound to a value, that binding never changes. If you write
val x = 3,xis3forever (in its scope). - Functions are first-class. A function is a value like any other: you can pass it to another function, store it in a variable, or return it from a function call.
Why this matters for AI: symbolic AI manipulates structured representations (parse trees, logical formulas, proofs). Pure functional code makes the structure of data explicit, makes programs easier to reason about formally, and lets the compiler perform aggressive optimizations. The downside — and a feature — is that SML deliberately omits loops, mutable variables, and objects; if you want them, you express them via recursion and higher-order functions.
val x = 3?