Thread overview
if(int a = 0) lowered to "if (int a = (int a = 1;) , a)" ?
Aug 08, 2018
aliak
Aug 08, 2018
Jonathan M Davis
Aug 08, 2018
Alex
Aug 08, 2018
aliak
Aug 08, 2018
Alex
August 08, 2018
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
August 08, 2018
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



August 08, 2018
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? ;)
August 08, 2018
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.
August 08, 2018
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... ))