Re: reasoning of evaluating code after return in current block (static if return)

2017-05-08 Thread Stefan Koch via Digitalmars-d
On Sunday, 7 May 2017 at 23:41:00 UTC, bastien penavayre wrote: On Sunday, 7 May 2017 at 23:20:26 UTC, Adam D. Ruppe wrote: [...] I just realized that I accidentally posted this while editing. I agree with you on that this is barely different from just adding "else". [...] compile your

Re: reasoning of evaluating code after return in current block (static if return)

2017-05-07 Thread bastien penavayre via Digitalmars-d
On Sunday, 7 May 2017 at 23:20:26 UTC, Adam D. Ruppe wrote: I would just write it `else static if` all on one line and not indent further. Then it barely looks any different anyway. I just realized that I accidentally posted this while editing. I agree with you on that this is barely

Re: reasoning of evaluating code after return in current block (static if return)

2017-05-07 Thread Adam D. Ruppe via Digitalmars-d
On Sunday, 7 May 2017 at 22:34:14 UTC, bastien penavayre wrote: Why is the code following "return true" evaluated ? It isn't evaluated, it is just compiled. The compile happens before it is run, so it doesn't really know if it is reachable yet. ClLinearExpression opBinary(string op)

reasoning of evaluating code after return in current block (static if return)

2017-05-07 Thread bastien penavayre via Digitalmars-d
Hi something's been bugging me for a while, for the following code: { auto t = tuple(0,0); return true; auto v = t[5]; return false; } Why is the code following "return true" evaluated ? I know that it's the same with the C++ but I was wondering why ? My guess is for goto/labels