If Statement with Declaration
Jerry via Digitalmars-d
digitalmars-d at puremagic.com
Fri Nov 4 23:57:01 PDT 2016
On Friday, 4 November 2016 at 19:26:23 UTC, Steven Schveighoffer
wrote:
>> I think it makes it easier to read and it fits with how the
>> for-statement operates. I write code everyday that could
>> utilize this
>> if-statement syntax, so I thought I might as well bring it up.
>> But if
>> there isn't that much interest in it then I won't bother with
>> a DIP.
>
> Please bear in mind that I'm not the gatekeeper, so what I say
> may not be what the actual ones in control think. It's possible
> that Walter and Andrei like the idea and would implement if
> someone fleshed out the proposal. In my experience, I have not
> encountered too many cases (definitely not zero though) where I
> needed such a feature. I can see the utility, and I wouldn't be
> opposed to it.
>
> -Steve
No but you do make a compelling case. Having the scope structured
the way you did removed the extra indention and it isn't as error
prone as the other methods. You could also have multiple
declarations which I don't think work (at least in the C++
implementation) for the new if-statement.
{int a; double b; if(func(&a, &b) >= 0)
{
}}
More information about the Digitalmars-d
mailing list