On Thursday, 24 July 2014 at 20:16:53 UTC, monarch_dodra wrote:

Or did I miss something?

Yes, sorry, I should have pasted a full example previously. The code at the end is with the Raw_met members renamed (they were originally a and b but clashed).

So, if Raw_met members were still a and b ...
  with(ar.r as v) with (ar.rm as res){
     res.a = v.a + v.c;
     res.b = (v.c==0)? 0: (v.a + v.b)/ v.c;

I don't recall the exact use case for the database expressions, but I believe they were substituting a simple symbol for the fully qualified object. So they would have done something analogous to this ...

with (ar.rm.a as d) with (ar.rm.b as e) with (ar.r.a as a) with (ar.r.b as b) with (ar.r.c as c){
     d = a + c;
     e = (c==0)?0:(a+b)/c;
}

So, the expressions are simpler to read, and I've fully qualified the members only a single time.



---- this is the code for one of the metric experiments, with the members renamed to avoid the clashes. I like that the expressions can be so simple.

double ref_clock=1_600_000_000.0;
struct Raw_met {long d; double e;}
struct Per_sec_met {double d; double e; }
struct Per_cyc_met {double d; double e; }


struct Raw {long proc_cyc; long a; long b; long c; }
struct Per_sec {double proc_cyc; double a; double b; double c; }
struct Per_cyc {double proc_cyc; double a; double b; double c; }
struct All { Raw r; Per_sec ps; Per_cyc pc; Raw_met rm; Per_sec_met psm; Per_cyc_met pcm;}


void calc_raw_met(ref All ar){
       with(ar.r) with(ar.rm){
         d = a+c;
         e = (c==0)?0:(a+b)/c;
       }
}

Reply via email to