Introduction

MATLAB is a programming language that provides scientists with an interactive development loop, high-level array operations and a rich collection of built-in and library functions. MATLAB is also a very dynamic language in which variable types are not declared, and in which new functions and scripts are loaded dynamically. Although MATLAB recently incorporated object-oriented programming features, there are currently no aspect-oriented features.

We have defined an extension of MATLAB, AspectMatlab, which supports the notions of patterns (pointcuts in AspectJ terminology), and named actions (advice in AspectJ terminology). An aspect in AspectMatlab looks very much like a class in the object-oriented part of MATLAB. Just like classes, an aspect can have properties (fields) and methods. However, in addition, the programmer can specify patterns (pointcuts) and before, after and around actions (advice). Each action is declared with a name (unlike advice in AspectJ, which do not have names).

AspectMatlab supports traditional patterns (pointcuts) such as call and execution, but we have also concentrated on an effective design for get and set patterns which naturally deal with arrays. Loops are key control structures in scientific programs and we have developed a collection of patterns which allow one to match on loops in a variety of ways. We have also been inspired by AspectCobol [2] in that we expose join point context information via selectors that are associated with actions.

We have implemented the amc compiler which translates AspectMatlab source files to pure MATLAB source files. The generated code can be run using any MATLAB system.

Toheed ASLAM 2010-04-24