aliasing/referencing expressions in with statements
deed via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Thu Apr 21 16:05:38 PDT 2016
Often I find myself wanting to alias an expression, such as
verbose fields, possibly nested. AFAIK, the with statement makes
it easier, but not as good as it could have been. What I'd like
to express is for example something like this:
with( a = instanceA.verboseFieldA.verboseFieldB,
b = instanceA.aDescriptiveName,
instanceC)
{
// use a, b and value:
b[value] = b[a + value] * (a*value)^^a;
}
// given:
struct A {
B verboseFieldA;
int[] aDescriptiveName;
...
}
struct B {
int verboseFieldB;
...
}
struct C {
int value;
...
}
A instanceA;
B instanceB;
C instanceC;
1) Is it possible to achieve something similar in D now? And if
not:
2) Are there any implementation considerations in this direction,
extending the with statement?
More information about the Digitalmars-d-learn
mailing list