Mixin Aspect-Orientation: Comments please!

Tony tq at tq.tq
Sun Jan 16 17:53:37 PST 2011


Hi, thanks for your reply but what you suggest is not enough.

With your solution you cannot add new advice without breaking stuff elsewhere. You don't want to clutter the namespace with lots of new function names. What you would want is to actually inject the code into the present functions.

What would make this even more modular is if you could use the mixin statement outside of the scope that you want to inject into by specifying the location:
    mixin acme.nuclear.Lollipop SomeAdvice;

That way you could extend code without touching its source.

Tony



Ary Borenszweig Wrote:

> You can already do that:
> 
> mixin template AdviceX() {
>   int fun(int x) {
>     ...
>     return fun_without_advice();
>   }
> }
> 
> class Foo {
>   mixin AdviceX;
> 
>   int fun_without_advice(int x) {
>   }
> }


More information about the Digitalmars-d mailing list