Language Constructs for Context-Oriented Programming
ContextL is an extension to the Common Lisp Object System that allows for Context-oriented Programming. It provides means to link partial class and method definitions with layers and to activate and deactivate such layers in the control flow of a running program. When a layer is activated, the partial definitions become part of the program until this layer is deactivated. This has the effect that the behavior of a program can be modified according to the context of its use without the need to mention such context dependencies in the affected base program. In this paper, it is illustrated these ideas by providing different UI views on the same object while, at the same time, keeping the conceptual simplicity of object oriented programming that objects know by themselves how to behave, in one's case how to display themselves. These seemingly contradictory goals can be achieved by separating class definitions into distinct layers instead of factoring out the display code into different classes. All these new constructs are integrated with the existing Common Lisp Object System (CLOS) , and this is achieved by implementing ContextL purely on top of the CLOS Metaobject Protocol. It is currently supported in seven major Common Lisp implementations and can be downloaded from http://common-lisp.net/project/closer. This paper does not provide any details on how ContextL is implemented but this will be reported in a future publication. In contrast to the more widely known class-based programming languages, CLOS itself is centered on the genericfunction- based approach to object-oriented programming. Work on systems implementing the key concepts of Context-oriented Programming in class-based languages, such as ContextS for Smalltalk, ContextT for Tweak, and ContextJ for Java is being carried out. This will give one the opportunity to understand better the core concepts of Context-oriented Programming, as well as their variations. Furthermore, one aims to explore the applicability of ContextL in various areas. For example, personalization, internationalization, ambient intelligence, context-sensitive safety and security, and testing frameworks that require simulation environments seem to be obvious candidates.