Suppose we are often writing something like
```d
theFirstName[theFirstIndex].theSecondName[theSecondIndex].thirdName[theThirdIndex]=x;
```
One would like to something like
```d
alias shortName = theFirstName[theFirstIndex].theSecondName[theSecondIndex].thirdName[theThirdIndex];
shortName = x;
```
but you can't alias an expression.

You can do
```d
(ref shortName) {
 shortName = x;

}(theFirstName[theFirstIndex].theSecondName[theSecondIndex].thirdName[theThirdIndex]);
```
but that doesn't read well since the ``definition'' of shortName comes at the end.

Another option is
```d
auto aliasAs(alias f,T)(ref T x) { return f(x); }

theFirstName[theFirstIndex].theSecondName[theSecondIndex].thirdName[theThirdIndex].aliasAs!
(ref shorName) {
 shortName = x;
}
```

Thoughts?

Reply via email to