Triggers

Sjoerd van Leent svanleent at gmail.com
Wed Aug 5 07:24:51 PDT 2009


OK, to make matters worse.

As I was reading so many things about properties, keywords and a bunch of other interesting things, perhaps triggers.

Triggers are, in my opinion, functions that act as delegates, and are called before or after one or more other functions. Maybe we can do something with this? It would introduce some aspect programming to D.

file 1:

class Foo
{
    int mybar;
    int myother;

    void bar(int i)
    {
        mybar = i;
    }


    void other(int i)
    {
        myother = i;
    }
}


file 2:

trigger(before) : "*.void * (int *)"
{
    writefln("calling ", this.currentFunctionName);
}

trigger(after) : "*.void * (int *)"
{
    writefln("called ", this.currentFunctionName);
}


This might be something for D3 though...



More information about the Digitalmars-d mailing list