7

I had recently read a paper 'Aspect-Oriented Programming' by Gregor Kiczales and others, and found there the loop fusion example.

Here is a definition of the loop fusion from the paper

…the loop fusion composes by fusing the loops of those primitive filters that have the same loop structure and that are direct neighbors in the data flow graph. Each of these composition rules is easy to understand when looking at its own appropriate picture. But the two composition relation- ships cut each other so fundamentally that each is very difficult to see in the other’s picture.

Later in the paper loop fusion mentioned to be implemented using metaobject protocol at Lisp:

…the loop fusion aspect … can be implemented, with some degree of efficiency, using the method combination facility in the CLOS metaobject protocol

What does loop fusion look like using any modern aspect-oriented frameworks in either static or dynamic typed languages? I'm looking for examples of aspect language and advices that could do loop fusion.

Status for mid-January'13

As long as there is no any other answer, I have marked my own answer as an answer. Anyway I'm still looking forward for examples from other languages/frameworks.

ps: loop fusion discusion at "AOP in .NET" book's forum @manning forum

2
  • 2
    From what I can gather, it kind of seems like implementing loop fusion using aspects is a horrendous misuse of aspects.
    – aroth
    Jan 8, 2013 at 11:27
  • Yes @aroth, I'm agree with you. But my profesional expirience is mainly at web and enterprise domain, thus I'm not sure about other domains like applied mathematics, modeling and others, where this could be useful. See my comment about PostSharp, AspectJ and DynamicProxy
    – Akim
    Jan 8, 2013 at 11:31

1 Answer 1

2

After initial paper released, Gregor Kiczales has started project AspectJ to implement an idea of Aspect-Oriented programming. Recently I found explanation why there are not "loop fusion" available at "AspectJ in Action" by Ramnivas Laddad:

In addition, the following are all join points: an object construction, a conditional check, a comparison, an exception handler, and even for, while, and do/while loops. Not all of the join points in a system are available for your use. … In order to prevent implementation-dependent or unstable crosscutting, AspectJ deliberately exposes only a subset of all the possible join points in the system. AspectJ, for example, does not expose for loops because you can easily change a for loop to a while loop that functions in the same manner. If such a change were to be made, all of the advice to the join point for the for loop would no longer be valid since the loop would no longer exist.

Another point I found at interview with Gael Fraiteur on PostSharp:

Some different people recommend AOP also for functional requirements and I... so really invasive in its aspects. Using PostSharp, you are forced to design aspects so that aspects don’t know their target code. They don’t know look how variables... so pay attention not to misuse PostSharp, not to misuse AOP, and respect also engineering principles, respect separation of concerns, and in the Java eco-system it is much, much longer concept and they have a lot of practice with it and users come with feel about that it’s more difficult to program with aspect because aspect has to know the target code. They have to know the implementation of target method and so on. Target method has to know they will be affected. I think this is a very bad design, and when you plan to use AOP, I recommend to design your base code and your AOP codes so that they don’t know about each other. It’s really important not to get completely mad with a small change.

So it's look like there is not "loop fusion" neither at AspectJ nor PostSharp, and Dynamic Proxy by it's definition could not provide this kind of functionality also

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.