digitalmars.D.learn - Bug or feature?
- mimi (22/22) May 26 2013 import std.stdio;
- Maxim Fomin (6/28) May 26 2013 alias does not capture this pointer, it is rewritten as
- mimi (2/2) May 27 2013 Well, how you can reduce the long ugly name in this case? In the
- Namespace (7/7) May 27 2013 void foo( S s )
- mimi (2/9) May 27 2013 By the way, yes. Thanks for that, I'm stupid today.
- Maxim Fomin (2/4) May 27 2013 By not making the name ugly big.
- mimi (7/11) May 27 2013 Other people do.
import std.stdio; struct S { int bigUglyName; void foo( S s ) { alias bigUglyName local; alias s.bigUglyName b; writeln( "bigUglyName (AKA local)=", local, " b=", b ); } } void main() { S s1; S s2; s1.bigUglyName = 1; s2.bigUglyName = 2; s1.foo( s2 ); } returns to console: bigUglyName (AKA local)=1 b=1 Why? I am expected that b=2
May 26 2013
On Sunday, 26 May 2013 at 23:35:43 UTC, mimi wrote:import std.stdio; struct S { int bigUglyName; void foo( S s ) { alias bigUglyName local; alias s.bigUglyName b; writeln( "bigUglyName (AKA local)=", local, " b=", b ); } } void main() { S s1; S s2; s1.bigUglyName = 1; s2.bigUglyName = 2; s1.foo( s2 ); } returns to console: bigUglyName (AKA local)=1 b=1 Why? I am expected that b=2alias does not capture this pointer, it is rewritten as S.bigUglyName and you can refer to non-static fields as Type.member which is this.member in member functions (in D semantic differences of accessing static and non-static members are diluted)
May 26 2013
Well, how you can reduce the long ugly name in this case? In the real function I mentioned it so many times.
May 27 2013
void foo( S s ) { auto local = this.bigUglyName; auto b = s.bigUglyName; writeln( "bigUglyName (AKA local)=", local, " b=", b ); } :P
May 27 2013
On Monday, 27 May 2013 at 10:17:01 UTC, Namespace wrote:void foo( S s ) { auto local = this.bigUglyName; auto b = s.bigUglyName; writeln( "bigUglyName (AKA local)=", local, " b=", b ); } :PBy the way, yes. Thanks for that, I'm stupid today.
May 27 2013
On Monday, 27 May 2013 at 10:07:49 UTC, mimi wrote:Well, how you can reduce the long ugly name in this case? In the real function I mentioned it so many times.By not making the name ugly big.
May 27 2013
On Monday, 27 May 2013 at 11:32:46 UTC, Maxim Fomin wrote:On Monday, 27 May 2013 at 10:07:49 UTC, mimi wrote:Other people do. In addition, sometimes you want to cut long nested queries such as: auto numOfPixelsDisplayed = Table.getItems( Scene.getObjectsArray() ).prepareForDisplay( type.GL ).showScene();Well, how you can reduce the long ugly name in this case? In the real function I mentioned it so many times.By not making the name ugly big.
May 27 2013