Discussion on Go and D

Andrej Mitrovic andrej.mitrovich at gmail.com
Sun Apr 8 17:21:46 PDT 2012


On 4/9/12, Andrei Alexandrescu <SeeWebsiteForEmail at erdani.org> wrote:
> and pass-by-alias

Speaking of alias, one killer feature would be to enable using alias
for expressions. E.g.:

struct Window { struct Point { int x, y; } Point point; }
void test() {
    Window window;
    alias window.point.x x;
    // use 'x' here which is really window.point.x
}

It makes it simpler to manipulate nested structs and their fields by
reference without involving pointers or using with statements. AFAIK
C++ can use references for this purpose (ala &int x =
window.point.x;), but I guess this isn't very efficient unless the
compiler can optimize it.

Besides myself I've also seen other people request it (I think Nick S.
wanted the feature).


More information about the Digitalmars-d mailing list