Today’s programming platforms do not provide sufficient constructs that allow a program’s behavior to depend on the context
in which it is executing. This paper presents the design and implementation of programming language extensions that explicitly
support our vision of Context-oriented Programming. In this model, programs can be partitioned into layers that can be dynamically
activated and deactivated depending on their execution context. Layers are sets of partial program definitions that can be
composed in any order. Context-oriented Programming encourages rich, dynamic modifications of program behavior at runtime,
requiring an efficient implementation. We present a dynamic representation of layers that yields competitive performance characteristics
for both layer activation/deactivation and overall program execution. We illustrate the performance of our implementation
by providing an alternative solution for one of the prominent examples of aspect-oriented programming.