Term Rewriting Meets Aspect-Oriented Programming

Paul Klint, Tijs van der Storm, Jurgen J. Vinju. Term Rewriting Meets Aspect-Oriented Programming. In Aart Middeldorp, Vincent van Oostrom, Femke van Raamsdonk, Roel C. de Vrijer, editors, Processes, Terms and Cycles: Steps on the Road to Infinity, Essays Dedicated to Jan Willem Klop, on the Occasion of His 60th Birthday. Volume 3838 of Lecture Notes in Computer Science, pages 88-105, Springer, 2005. [doi]

Abstract

We explore the connection between term rewriting systems (TRS) and aspect-oriented programming (AOP). Term rewriting is a para-digm that is used in fields such as program transformation and theorem proving. AOP is a method for decomposing software, complementary to the usual separation into programs, classes, functions, etc. An aspect represents code that is scattered across the components of an otherwise orderly decomposed system. Using AOP, such code can be modularized into aspects and then automatically weaved into a system.

Aspect weavers are available for only a handful of languages. Term rewriting can offer a method for the rapid prototyping of weavers for more languages. We explore this claim by presenting a simple weaver implemented as a TRS.

We also observe that TRS can benefit from AOP. For example, their flexibility can be enhanced by factoring out hardwired code for tracing and logging rewrite rules. We explore methods for enhancing TRS with aspects and present one application: automatically connecting an interactive debugger to a language specification.