Value and Reference model of variables, revisited

Functional languages generally employ a reference model for names (a purely functional language has no variables or assignments). In C, which employs a value model, pointers are needed to deal with references.

Files and I/O

Handled very differently between languages, usually very difficult

Chapter 6 - Control Flow - Scott

Ordering

How to determine what should be done first, second, etc?

  • Sequencing- Statements are to be executed in a specified order, usually in the order they appear in program text
  • Selection- a choice is to be made among two or more statements or expressions
  • Iteration- A given fragment of code is to be executed repeatedly
  • Procedural abstraction - A potentially complex collection of control constructs is encapsulated in a way that allows it to be treated as a single unit, usually subject to parameterization
  • Recursion
  • Concurrency
  • Exception handling and speculation
  • Nondeterminacy- Ordering among statements is deliberately left unspecified. All alternatives should lead to a correct result

Precedence is a language design choice; C has 15 levels of precedence for expression evaluation!

Referential Transparency

The value of an expression depends only on its referencing environment, not when it is evaluated. Pure functional languages are referentially transparent.

Expressions and statements

Recall: Expressions always produce a value, may or may not have side effects. Statements executed solely for side effects (e.g., assignments).

Boxing

Automatic conversion between value and reference models