Values of Expressions
Understand the difference between syntax and semantics of expressions as well as how expression evaluation works.
We'll cover the following...
Syntax vs. semantics
When studying languages in general and programming languages in particular, it is worth learning to differentiate between syntax and semantics. The syntax of a language specifies which character combinations are valid and which aren’t. This lesson focuses on semantics, which is concerned with the meaning of those character combinations.
Consider, for instance, the expression 12 + 34
.
What we enter is nothing more than a string—a character combination— consisting of characters 1
, 2
, 3
, 4
, empty space, +
, and so on.
The OCaml parser recognizes this input, and creates an abstract syntax tree to represent the expression. Until this point, it’s been all ...