Re: if(int a = 0) lowered to "if (int a = (int a = 1;) , a)" ?

2018-08-08 Thread Alex via Digitalmars-d-learn

On Wednesday, 8 August 2018 at 13:13:24 UTC, aliak wrote:


Go here https://run.dlang.io/is/tJ4vXm and click on the AST 
button :) It shows you what the code turns in to after all the 
semantic passes.


Yeah... no... I'm aware of this cool thing ))
I thought you have a hidden source of knowledge, where all 
available transformations back and fore are specified, somehow... 
))


Re: if(int a = 0) lowered to "if (int a = (int a = 1;) , a)" ?

2018-08-08 Thread aliak via Digitalmars-d-learn

On Wednesday, 8 August 2018 at 12:58:24 UTC, Alex wrote:

On Wednesday, 8 August 2018 at 11:58:50 UTC, aliak wrote:

Found this out while just looking at lowerings.


How do you "look at lowerings"? Is there a list, I'm not aware 
of? ;)


Go here https://run.dlang.io/is/tJ4vXm and click on the AST 
button :) It shows you what the code turns in to after all the 
semantic passes.


Re: if(int a = 0) lowered to "if (int a = (int a = 1;) , a)" ?

2018-08-08 Thread Alex via Digitalmars-d-learn

On Wednesday, 8 August 2018 at 11:58:50 UTC, aliak wrote:

Found this out while just looking at lowerings.


How do you "look at lowerings"? Is there a list, I'm not aware 
of? ;)


Re: if(int a = 0) lowered to "if (int a = (int a = 1;) , a)" ?

2018-08-08 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, August 8, 2018 5:58:50 AM MDT aliak via Digitalmars-d-learn 
wrote:
> Found this out while just looking at lowerings. Wondering if
> anyone knows the semantics involved here and where they are
> documented?

It's particularly useful when dealing with stuff like C functions that
return 0 on success or getting values from AAs. e.g.

if(auto value = key in aa)
{
}

> And, is there anyway to do it with multiple variables?
>
> I.e.
>
> if (int a = 0, int b = 0) {
>   // ...
> }

I don't believe so.

- Jonathan M Davis





if(int a = 0) lowered to "if (int a = (int a = 1;) , a)" ?

2018-08-08 Thread aliak via Digitalmars-d-learn
Found this out while just looking at lowerings. Wondering if 
anyone knows the semantics involved here and where they are 
documented?


And, is there anyway to do it with multiple variables?

I.e.

if (int a = 0, int b = 0) {
 // ...
}


Cheers,
- Ali