Recitation 2

  1. In your own words, explain the difference between syntax and semantics. Also explain the difference between static semantics and dynamic semantics.

  2. The section on scope in the textbook discusses this expression:
    let x = 5 in 
      ((let x = 6 in x) + x)
    

    Using the dynamic semanics of let expressions, explain how that expression evaluates.

  3. Run the following code in the toplevel.
    let x = 1;;
    let x = 2;;
    x;;
    

    Why is it valid to say that variables in OCaml are immutable, despite the output of utop? Your answer should incorporate the ideas of shadowing and nested let expressions.

Submit to CMS: Submit your written responses to the questions above. As always, keep them brief: no more than one page total.