Sjoerd van Leent Wrote:
> 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...
You can already do something like that, although very hackish: turn on trace
profiling and override the prolog/epilog code from druntime (I think these are
called _trace_pro_n and _trace_epi_n, just grep the source for their syntax).
Just make *very* sure to use only naked declarations in these and any routine
they may call, or else you will just call back into _trace_pro_n until you get
a stack overflow.