Re: Unreachable warning is annoying

2018-03-15 Thread Ali Çehreli via Digitalmars-d
On 03/15/2018 04:27 PM, Steven Schveighoffer wrote: Note, I replied with the following text, but for some reason the forum does NOT see this post. It should be here: https://forum.dlang.org/post/p8990d$2ona$1...@digitalmars.com And it does exist on the NNTP server. It was received by Thunde

Re: Unreachable warning is annoying

2018-03-15 Thread Steven Schveighoffer via Digitalmars-d
On 3/13/18 3:21 PM, Timon Gehr wrote: On 13.03.2018 18:43, H. S. Teoh wrote: On Tue, Mar 13, 2018 at 01:32:55PM -0400, Steven Schveighoffer via Digitalmars-d wrote: [...] An unrolled foreach on a tuple has a notion that the flow control jumps out of the loop, and it's OK to skip further loops

Re: Unreachable warning is annoying

2018-03-13 Thread Steven Schveighoffer via Digitalmars-d
On 3/13/18 3:21 PM, Timon Gehr wrote: On 13.03.2018 18:43, H. S. Teoh wrote: On Tue, Mar 13, 2018 at 01:32:55PM -0400, Steven Schveighoffer via Digitalmars-d wrote: [...] An unrolled foreach on a tuple has a notion that the flow control jumps out of the loop, and it's OK to skip further loops

Re: Unreachable warning is annoying

2018-03-13 Thread Timon Gehr via Digitalmars-d
On 13.03.2018 18:43, H. S. Teoh wrote: On Tue, Mar 13, 2018 at 01:32:55PM -0400, Steven Schveighoffer via Digitalmars-d wrote: [...] An unrolled foreach on a tuple has a notion that the flow control jumps out of the loop, and it's OK to skip further loops (even though they are technically unrol

Re: Unreachable warning is annoying

2018-03-13 Thread H. S. Teoh via Digitalmars-d
On Tue, Mar 13, 2018 at 01:32:55PM -0400, Steven Schveighoffer via Digitalmars-d wrote: [...] > An unrolled foreach on a tuple has a notion that the flow control > jumps out of the loop, and it's OK to skip further loops (even though > they are technically unrolled). [...] This is not true. Fore

Re: Unreachable warning is annoying

2018-03-13 Thread Steven Schveighoffer via Digitalmars-d
On 3/13/18 12:50 PM, Yuxuan Shui wrote: On Tuesday, 13 March 2018 at 14:40:21 UTC, Steven Schveighoffer wrote: On 3/13/18 10:25 AM, Yuxuan Shui wrote: [...] This has been discussed before. There are a few ways around this. One is to do what you did. Another is to append a sentinel, or use id

Re: Unreachable warning is annoying

2018-03-13 Thread Yuxuan Shui via Digitalmars-d
On Tuesday, 13 March 2018 at 14:40:21 UTC, Steven Schveighoffer wrote: On 3/13/18 10:25 AM, Yuxuan Shui wrote: [...] This has been discussed before. There are a few ways around this. One is to do what you did. Another is to append a sentinel, or use id to terminate the loop: foreach(id, R;

Re: Unreachable warning is annoying

2018-03-13 Thread Steven Schveighoffer via Digitalmars-d
On 3/13/18 10:25 AM, Yuxuan Shui wrote: See this simple example: int staticFind(T, S...)() {     foreach(id, R; S) {     if (is(T == R))     return id;     }     }     return -1; } staticFind!(int, int, double) will generate a 'statement is unreachable' warning, and stati

Unreachable warning is annoying

2018-03-13 Thread Yuxuan Shui via Digitalmars-d
See this simple example: int staticFind(T, S...)() { foreach(id, R; S) { if (is(T == R)) return id; } } return -1; } staticFind!(int, int, double) will generate a 'statement is unreachable' warning, and staticFind!(int, double) won't. This behaviour is