[Issue 16123] alias member of member
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Mon Jun 6 09:59:22 PDT 2016
https://issues.dlang.org/show_bug.cgi?id=16123
Max Samukha <maxsamukha at gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |maxsamukha at gmail.com
--- Comment #3 from Max Samukha <maxsamukha at gmail.com> ---
(In reply to Steven Schveighoffer from comment #2)
> (In reply to Sobirari Muhomori from comment #1)
>
> > struct T
> > {
> > S s;
> > alias y = S.x; // what this means?
> > }
>
> Right, but I said s.x, not S.x. It means alias to the member x of the
> instance of S called s, which resides in this instance of T.
In 'alias', they are just two equivalent ways of referencing 'x', that is:
__traits(isSame, S.x, T.s.x) == true
And it kind of makes sense if you think of 'alias' as little more than a means
of creating synonyms for a symbol. With 's.x' in the 'alias' declaration, you
are simply importing 'x' to the namespace of 'T'. Not that I care much now, but
some code I wrote actually relied on this semantics.
--
More information about the Digitalmars-d-bugs
mailing list