The intension as first-class value

The origins of Cartesian Programming came from what was called Intensional Programming, in which the behavior of a program was context-dependent: a context is a set of (dimension,ordinate) pairs,
and the program can change behavior if some of the ordinates are changed. Formally, a variable in an intensional programming language is an intension, i.e., a mapping from contexts to values.

In TransLucid, after several failed attempts at defining the semantics of functions over these intensions, it finally dawned on us that the intension itself needs to be a first-class value. What this means is that
the context in which an intension is created is as important as the context in which it is evaluated. Consider:

var tempAtLocation = ↑{location} temperature ;;
var tempInInuvik = tempAtLocation @ [location ← "Inuvik"] ;;

What this means is that whatever the value of the location-ordinate, variable tempInInuvik would always give the temperature in Inuvik, allowing any other dimensions to vary freely. Hence

↓tempInInuvik @ [location ← "Paris", date ← #!date - 1] ;;

would give the temperature in Inuvik yesterday, not in Paris yesterday.

Advertisements