Modular Monadic Semantics for Aspect-Oriented Programming

This research examines the use of modular monadic semantics to specify the semantics of aspect oriented languages. Aspect-oriented programming [5] is a paradigm where different facets of a system’s behavior are programmed independently. Aspect languages then provide a mechanism for “weaving” the different behavior into a complete program. A principal criticism of the paradigm is the difficulty in reasoning about the interaction of different aspects in a woven system. The aspect language is expressed in terms of the object language, eliminating the distinction between the aspect meta-language and the object language. There have been several formulations of semantic definitions of AOP constructs. Wand [15] gave an early dynamic semantics for AOP. Lammel provided an alternative semantics based on method-call interception and superimposition. Later work extended by separated static and dynamic aspect semantics, yielding significant efficiency gains [12, 14]. Modular monadic semantics [2, 11, 13] was first introduced as a method for independently specifying denotations for various language constructs. This work focused on specification of modular interpreters; follow-on work examined the usefulness of modular monadic semantics for building and proving correctness of compilers [10, 3]. While the early work focused on independent specification of language constructs, it still coupled the language constructs by requiring them to be members of the same abstract syntax data type. A solution to this problem models algebraic data types as least fixed-points of functors. Each language element is represented as a single functor. This model allows language elements to be specified completely independently as algebras over a functor [4, 1, 6, 7, 8, 4]. An interpretation is then simply the folding of the collection of algebras for the language. Our work builds on the idea of semantics as functors. In contrast to the work above, which defines an algebra as a simple function over a functor, we represent an algebra as an explicitly as a data type with function valued members [9]. Doing this allows us to dynamically update the algebras. The use of updatable algebras facilitate the treatment of the aspect weaving process formally as a metaprogramming activity. Traditional language constructs are specified as updatable algebras. Aspect language semantics are specified as transformations on those semantic algebras. By using modular monadic semantics with updatable algebras, we expect to realize several benefits. Composability allows experimentation with various AOP semantic definitions. Additionally, updatable algebras provide a clear separation between the aspect meta-language semantics and the object language semantics, simplifying reasoning about a composed system. Finally, monadic semantics provides a convenient mechanism for staging compilers, allowing the separation of the dynamic and static semantics of aspect languages.