dual with statement
Jay Norwood via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Fri Jul 25 06:21:44 PDT 2014
On Friday, 25 July 2014 at 01:54:53 UTC, Jay Norwood wrote:
> 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.
The sql with clause is quite a bit different than I remembered.
For one thing, I have the order reversed, so it would have been
with (a as something.x.y).
It looks more like they are more like creating a temporary tuple
from some more complicated selection. It isn't clear what the
implementation is, but just the that it might be a more concise
way of stating things so that the expressions inside the body can
be simple
So, my prior example
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;
}
would reduce to something maybe simpler to read. The sql seems
to be using this as a foreach type operation, but I was just
interested in the name substitution so that the expressions
inside the with block could be simpler, as well as get rid of the
struct member name clashes.
with ( (d,e,a,b,c) as (ar.rm.a, ar.rm.b, ar.r.a, ar.r.b, ar.r.c)){
d = a + c;
e = (c==0)?0:(a+b)/c;
}
More information about the Digitalmars-d-learn
mailing list