Thread overview | |||||||||
---|---|---|---|---|---|---|---|---|---|
|
May 26, 2013 Bug or feature? | ||||
---|---|---|---|---|
| ||||
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 27, 2013 Re: Bug or feature? | ||||
---|---|---|---|---|
| ||||
Posted in reply to mimi | 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=2
alias 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 27, 2013 Re: Bug or feature? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Maxim Fomin | 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 Re: Bug or feature? | ||||
---|---|---|---|---|
| ||||
Posted in reply to mimi | void foo( S s ) { auto local = this.bigUglyName; auto b = s.bigUglyName; writeln( "bigUglyName (AKA local)=", local, " b=", b ); } :P |
May 27, 2013 Re: Bug or feature? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Namespace | 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 );
> }
>
> :P
By the way, yes. Thanks for that, I'm stupid today.
|
May 27, 2013 Re: Bug or feature? | ||||
---|---|---|---|---|
| ||||
Posted in reply to mimi | 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 Re: Bug or feature? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Maxim Fomin | 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:
>> 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.
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();
|
Copyright © 1999-2021 by the D Language Foundation