emulate with

Amex Amex at gmail.com
Fri May 31 07:17:22 UTC 2019


with lets one remove a direct reference...

The problem is the things I want to access are not part of a 
single object but have a common naming structure:

X_A
X_B
X_C_Q

(rather than X.A, X.B, X.C.Q)

it would be very helpful(since X is long) to be able to do 
something like

with(X)
{
     A;
     B;
     C_Q;
}

or even

with(X)
{
     A;
     B;
     with(C)
     {
         Q;
     }
}


I imagine this can actually be done with dispatching because one 
could use opDispatch to redirect. The problem is that this 
requires filling out the info which sorta defeated the 
purpose(unless it's used often).

What I'm talking about is that if A would be dispatched to, say, 
W!X where W handles the special dispatching by returning X_A 
rather than X.A.


I don't know if D can do this kinda stuff even though it would be 
rather simple as it would depend on with.

e.g., would be cool if there was an opWith ;)





More information about the Digitalmars-d-learn mailing list