| Thread overview | |||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
June 24, 2016 static if enhancement | ||||
|---|---|---|---|---|
| ||||
Does anyone else find this annoying? https://issues.dlang.org/show_bug.cgi?id=16201 -- Andrei | ||||
June 24, 2016 Re: static if enhancement | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | On 6/24/16 11:24 AM, Andrei Alexandrescu wrote:
> Does anyone else find this annoying?
> https://issues.dlang.org/show_bug.cgi?id=16201 -- Andrei
Maybe. That bug report does not identify any problems. What happens that's currently bad?
-Steve
| |||
June 24, 2016 Re: static if enhancement | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | On Friday, 24 June 2016 at 15:24:48 UTC, Andrei Alexandrescu wrote:
> Does anyone else find this annoying? https://issues.dlang.org/show_bug.cgi?id=16201 -- Andrei
This would mean treating static if's differently if they alter control flow in a scope larger then themselves.
Special casing a static if that returns would not be as bad.
But with the current state of the compiler I would hold of on such complications.
| |||
June 24, 2016 Re: static if enhancement | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Stefan Koch | On Friday, 24 June 2016 at 15:34:42 UTC, Stefan Koch wrote:
> On Friday, 24 June 2016 at 15:24:48 UTC, Andrei Alexandrescu wrote:
>> Does anyone else find this annoying? https://issues.dlang.org/show_bug.cgi?id=16201 -- Andrei
>
> This would mean treating static if's differently if they alter control flow in a scope larger then themselves.
>
> Special casing a static if that returns would not be as bad.
> But with the current state of the compiler I would hold of on such complications.
To elaborate:
This requires control-flow analysis over all static if branches,
to find and very one special case which we treat specially.
It would only be beneficial If we hit this case predominantly.
However, I am not sure how much langauge complexity this adds.
| |||
June 24, 2016 Re: static if enhancement | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Steven Schveighoffer | On Friday, 24 June 2016 at 15:29:18 UTC, Steven Schveighoffer wrote: > On 6/24/16 11:24 AM, Andrei Alexandrescu wrote: >> Does anyone else find this annoying? >> https://issues.dlang.org/show_bug.cgi?id=16201 -- Andrei > > Maybe. That bug report does not identify any problems. What happens that's currently bad? > > -Steve Same question: What is the actual problem ? One issue that can arise is https://issues.dlang.org/show_bug.cgi?id=14835 . Is there any other ? | |||
June 24, 2016 Re: static if enhancement | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Mathias Lang | On 06/24/2016 11:47 AM, Mathias Lang wrote:
> On Friday, 24 June 2016 at 15:29:18 UTC, Steven Schveighoffer wrote:
>> On 6/24/16 11:24 AM, Andrei Alexandrescu wrote:
>>> Does anyone else find this annoying?
>>> https://issues.dlang.org/show_bug.cgi?id=16201 -- Andrei
>>
>> Maybe. That bug report does not identify any problems. What happens
>> that's currently bad?
>>
>> -Steve
>
> Same question: What is the actual problem ?
> One issue that can arise is
> https://issues.dlang.org/show_bug.cgi?id=14835 . Is there any other ?
The problem is excessive indentation. -- Andrei
| |||
June 24, 2016 Re: static if enhancement | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Steven Schveighoffer | On Friday, 24 June 2016 at 15:29:18 UTC, Steven Schveighoffer wrote:
> On 6/24/16 11:24 AM, Andrei Alexandrescu wrote:
>> Does anyone else find this annoying?
>> https://issues.dlang.org/show_bug.cgi?id=16201 -- Andrei
>
> Maybe. That bug report does not identify any problems. What happens that's currently bad?
>
> -Steve
Second that, can't see anything bad there!
| |||
June 24, 2016 Re: static if enhancement | ||||
|---|---|---|---|---|
| ||||
Posted in reply to JohnnyC | On Friday, 24 June 2016 at 17:03:55 UTC, JohnnyC wrote:
> On Friday, 24 June 2016 at 15:29:18 UTC, Steven Schveighoffer wrote:
>> On 6/24/16 11:24 AM, Andrei Alexandrescu wrote:
>>> Does anyone else find this annoying?
>>> https://issues.dlang.org/show_bug.cgi?id=16201 -- Andrei
>>
>> Maybe. That bug report does not identify any problems. What happens that's currently bad?
>>
>> -Steve
>
> Second that, can't see anything bad there!
The problem (that I see) is, that if you don't create the "else" path but the "static if" condition is true, you generate dead code behind the return statement (if the compiler doesn't optimize that away).
In our company that would be a no-go. So you always have to explicitly write (and indent) the else path.
| |||
June 24, 2016 Re: static if enhancement | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | On 6/24/16 12:19 PM, Andrei Alexandrescu wrote:
> On 06/24/2016 11:47 AM, Mathias Lang wrote:
>> On Friday, 24 June 2016 at 15:29:18 UTC, Steven Schveighoffer wrote:
>>> On 6/24/16 11:24 AM, Andrei Alexandrescu wrote:
>>>> Does anyone else find this annoying?
>>>> https://issues.dlang.org/show_bug.cgi?id=16201 -- Andrei
>>>
>>> Maybe. That bug report does not identify any problems. What happens
>>> that's currently bad?
>>>
>>
>> Same question: What is the actual problem ?
>> One issue that can arise is
>> https://issues.dlang.org/show_bug.cgi?id=14835 . Is there any other ?
>
> The problem is excessive indentation. -- Andrei
The problem that hasn't been made clear is, why can't you just write:
static if(condition)
{
... // some code
return;
}
// some more code
And the answer is, I'm guessing, bug 14835 -- misguided "unreachable statement" warnings.
Should we mark your bug as a duplicate?
-Steve
| |||
June 24, 2016 Re: static if enhancement | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Steven Schveighoffer | On 6/24/16 1:15 PM, Steven Schveighoffer wrote:
> The problem that hasn't been made clear is, why can't you just write:
>
> static if(condition)
> {
> ... // some code
> return;
> }
>
> // some more code
>
> And the answer is, I'm guessing, bug 14835 -- misguided "unreachable
> statement" warnings.
>
> Should we mark your bug as a duplicate?
Sorry, the problem is that the code doesn't compile at all if the static if is false. So I need to insert the "else".
The compiler should not attempt at all to compile the code after the static if.
Andrei
| |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply