Re: bug in foreach continue

2017-03-24 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Mar 23, 2017 at 05:11:49PM +, Adam D. Ruppe via Digitalmars-d-learn wrote: > On Thursday, 23 March 2017 at 00:39:56 UTC, H. S. Teoh wrote: > > I'm still working on that. :-) > > Hey, can you at least put scare quotes around "static foreach" each > time it is used? There's no such

Re: bug in foreach continue

2017-03-23 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 23 March 2017 at 00:39:56 UTC, H. S. Teoh wrote: I'm still working on that. :-) Hey, can you at least put scare quotes around "static foreach" each time it is used? There's no such thing as static foreach and while we might call foreach over a typetuple "static", it isn't a

Re: bug in foreach continue

2017-03-22 Thread Ali Çehreli via Digitalmars-d-learn
On 03/22/2017 05:39 PM, H. S. Teoh via Digitalmars-d-learn wrote: > the article is turning out to be quite a bit longer I said "book"; didn't I? :) Ali

Re: bug in foreach continue

2017-03-22 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Mar 22, 2017 at 11:12:06PM +, Jesse Phillips via Digitalmars-d-learn wrote: > On Friday, 17 March 2017 at 19:05:20 UTC, H. S. Teoh wrote: > > There are actually (at least) TWO distinct phases of compilation > > that are conventionally labelled "compile time": > > > > 1) Template

Re: bug in foreach continue

2017-03-22 Thread Jesse Phillips via Digitalmars-d-learn
On Friday, 17 March 2017 at 19:05:20 UTC, H. S. Teoh wrote: There are actually (at least) TWO distinct phases of compilation that are conventionally labelled "compile time": 1) Template expansion / AST manipulation, and: 2) CTFE (compile-time function evaluation). This was an awesome

Re: bug in foreach continue

2017-03-21 Thread Stefan Koch via Digitalmars-d-learn
On Friday, 17 March 2017 at 19:05:20 UTC, H. S. Teoh wrote: There are actually (at least) TWO distinct phases of compilation that are conventionally labelled "compile time": 1) Template expansion / AST manipulation, and: 2) CTFE (compile-time function evaluation). [ ... ] Template

Re: bug in foreach continue

2017-03-18 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 19 March 2017 at 00:18:15 UTC, H. S. Teoh wrote: Haha, I don't think I'm up for writing a book... and I don't really keep a blog either. But perhaps a writeup on wiki.dlang.org is in order. This particular topic, I think, is something somebody *should* write about, because it

Re: bug in foreach continue

2017-03-18 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, March 18, 2017 17:18:15 H. S. Teoh via Digitalmars-d-learn wrote: > On Fri, Mar 17, 2017 at 02:52:39PM -0700, Ali Çehreli via Digitalmars-d- learn wrote: > > On 03/17/2017 12:05 PM, H. S. Teoh via Digitalmars-d-learn wrote: > > > 1) Template expansion / AST manipulation, and: > > > >

Re: bug in foreach continue

2017-03-18 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Mar 17, 2017 at 02:52:39PM -0700, Ali Çehreli via Digitalmars-d-learn wrote: > On 03/17/2017 12:05 PM, H. S. Teoh via Digitalmars-d-learn wrote: > > > 1) Template expansion / AST manipulation, and: > > > > 2) CTFE (compile-time function evaluation). > > > > Not clearly understanding

Re: bug in foreach continue

2017-03-17 Thread Hussien via Digitalmars-d-learn
On Friday, 17 March 2017 at 19:05:20 UTC, H. S. Teoh wrote: On Fri, Mar 17, 2017 at 03:14:08PM +, Hussien via Digitalmars-d-learn wrote: [...] [...] This appears to be yet another case of the term "compile-time" causing confusion, because it's actually an ambiguous term. I actually

Re: bug in foreach continue

2017-03-17 Thread Ali Çehreli via Digitalmars-d-learn
On 03/17/2017 12:05 PM, H. S. Teoh via Digitalmars-d-learn wrote: 1) Template expansion / AST manipulation, and: 2) CTFE (compile-time function evaluation). Not clearly understanding the distinction between the two often leads to confusion and frustration at why the compiler isn't doing "what

Re: bug in foreach continue

2017-03-17 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Mar 17, 2017 at 03:14:08PM +, Hussien via Digitalmars-d-learn wrote: [...] > What I am talking about is > > how the statement > > static if (x) continue; > pragma(msg, "called"); > > vs > > static if (x) { } else > pragma(msg, "not called"); > > > They are both semantically

Re: bug in foreach continue

2017-03-17 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 17 March 2017 at 15:14:08 UTC, Hussien wrote: What I am talking about is If you want to add a new feature, `static foreach`, that has static continue and static break, I can get behind that, but that's a new feature, not a bug in the existing feature. You think it is something it

Re: bug in foreach continue

2017-03-17 Thread Hussien via Digitalmars-d-learn
On Friday, 17 March 2017 at 14:27:25 UTC, Adam D. Ruppe wrote: On Friday, 17 March 2017 at 13:53:58 UTC, Hussien wrote: Yes, but you have a nested foreach loop. One runtime and one compile time. The break goes with the runtime loop... but NORMAL programming logic tells us that the break goes

Re: bug in foreach continue

2017-03-17 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 17 March 2017 at 13:53:58 UTC, Hussien wrote: Yes, but you have a nested foreach loop. One runtime and one compile time. The break goes with the runtime loop... but NORMAL programming logic tells us that the break goes with the loop that it exists in. It did. It broke the loop

Re: bug in foreach continue

2017-03-17 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 17 March 2017 at 13:10:23 UTC, Jonathan M Davis wrote: it looks like break and continue _are_ used at compile time, since it prints They are working exactly the same way as any other loop. The fact that it is unrolled and the dead code removed from the binary is an implementation

Re: bug in foreach continue

2017-03-17 Thread Hussien via Digitalmars-d-learn
On Friday, 17 March 2017 at 13:10:23 UTC, Jonathan M Davis wrote: On Friday, March 17, 2017 11:53:41 Michael via Digitalmars-d-learn wrote: On Friday, 17 March 2017 at 11:30:48 UTC, Jonathan M Davis wrote: > On Friday, March 17, 2017 01:55:19 Hussien via > Digitalmars-d-learn wrote: > > I

Re: bug in foreach continue

2017-03-17 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, March 17, 2017 11:53:41 Michael via Digitalmars-d-learn wrote: > On Friday, 17 March 2017 at 11:30:48 UTC, Jonathan M Davis wrote: > > On Friday, March 17, 2017 01:55:19 Hussien via > > Digitalmars-d-learn wrote: > > > > I tend to agree with this. If the foreach is static, and > >

Re: bug in foreach continue

2017-03-17 Thread Michael via Digitalmars-d-learn
On Friday, 17 March 2017 at 11:30:48 UTC, Jonathan M Davis wrote: On Friday, March 17, 2017 01:55:19 Hussien via Digitalmars-d-learn wrote: I tend to agree with this. If the foreach is static, and continue and break are just going to be ignored, then they should just be illegal. Allowing

Re: bug in foreach continue

2017-03-17 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, March 17, 2017 01:55:19 Hussien via Digitalmars-d-learn wrote: > On Friday, 17 March 2017 at 01:41:47 UTC, Adam D. Ruppe wrote: > > On Friday, 17 March 2017 at 01:34:52 UTC, Hussien wrote: > >> Seems like continue needs to be static aware. > > > > That's not a bug, pragma is triggered

Re: bug in foreach continue

2017-03-17 Thread Daniel Kozak via Digitalmars-d-learn
Dne 17.3.2017 v 02:34 Hussien via Digitalmars-d-learn napsal(a): foreach (y; aliasSeqOf!["a", "b", "c"]) { static if (y == "a") { } else pragma(msg, y); } works but foreach (y; aliasSeqOf!["a", "b", "c"]) { static if (y == "a") continue pragma(msg, y); } fails. Seems like continue needs to

Re: bug in foreach continue

2017-03-16 Thread Hussien via Digitalmars-d-learn
On Friday, 17 March 2017 at 01:41:47 UTC, Adam D. Ruppe wrote: On Friday, 17 March 2017 at 01:34:52 UTC, Hussien wrote: Seems like continue needs to be static aware. That's not a bug, pragma is triggered when the code is *compiled*, not when it is run. The code is compiled, even if it is

Re: bug in foreach continue

2017-03-16 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 17 March 2017 at 01:34:52 UTC, Hussien wrote: Seems like continue needs to be static aware. That's not a bug, pragma is triggered when the code is *compiled*, not when it is run. The code is compiled, even if it is skipped over by a continue.

bug in foreach continue

2017-03-16 Thread Hussien via Digitalmars-d-learn
foreach (y; aliasSeqOf!["a", "b", "c"]) { static if (y == "a") { } else pragma(msg, y); } works but foreach (y; aliasSeqOf!["a", "b", "c"]) { static if (y == "a") continue pragma(msg, y); } fails. Seems like continue needs to be static aware. This leads to subtle bugs where one thinks the