AspectMatlab introduces key aspect-oriented features in a way that is both accessible to scientists and where the aspect-oriented features concentrate on array accesses and loops, the core computation elements in scientific programs. Introducing aspects into a dynamic language such as Matlab also provides some new challenges. In particular, it is difficult to statically determine precisely where patterns match, resulting in many dynamic checks in the woven code. AspectMatlab Compiler (amc) includes flow analyses which are used to eliminate many of those dynamic checks.
- Paper:  AspectMatlab: An Aspect-Oriented Scientific Programming Language
- Thesis:  AspectMatlab: An Aspect-Oriented Scientific Programming Language
- Technical Report:  AspectMatlab: An Aspect-Oriented Scientific Programming Language
- Paper:  Typing Aspects for MATLAB
The new AspectMatlab release addresses the following issues:
Support for the MATLAB clear statements
The MATLAB clear removes variables and functions from memory. After weaving the actions of an aspect at joinpoints, the resultant MATLAB program contains both user-defined variables and variables defined by AspectMatlab. A clear statement executed by the program could remove variables defined by AspectMatlab and this could have a fatal effect on the program. This problem has been addressed in the current version of AspectMatlab.
Support for end expression used in a compound expression:
The Matlab end expression refers to the last index in an indexing expression. AspectMatlab transforms a compound expression into simple expressions using temporary variables. The problem addressed by this extension is the potential loss of the association of an “end” expression with the innermost array variable in a compound expression. For example, in the expression y(a(foo(end),1)), where y and a are array variables and foo is a function, end refers to the index of the last element of a. If AspectMatlab was to simplify foo(end) out of the compound expression, the association with the array a would be lost.
Language extension for defining patterns for matching arithmetic operators:
The MATLAB programming language defines a variety of operators and the previous version of AspectMatlab is incapable of matching patterns based on these operators. Operations had to be matched based on functions. The new version of AspectMatlab allows programmers to define aspects that match directly arithmetic operations based on operators.
Once you have a copy of amc.jar, you can execute the jar directly with a list of standard Matlab files along with AspectMatlab aspect files.
For example, one might run java -jar amc.jar myFunc.m myAspect.m.
You will find woven code generated by amc in weaved directory in the current working directory, which can be executed using any Matlab system.
A list of aspect and base programs along with amc generated woven code is given here.