bug in foreach continue

Jonathan M Davis via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Mar 18 18:31:09 PDT 2017


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:
> > >
> > > 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 I want".
> >
> > I always find your posts very informative and very well articulated.
> > Where is the book already? :) Or blog posts?
>
> [...]
>
> 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 seems to trip up newbies quite often.  Maybe sometimes
> even seasoned D users get tripped up, too (though they tend to know
> better where the problem is and how to work around it).  And this isn't
> the first time I wrote about it.  I guess it's time to consolidate what
> I've written into a wiki article.

For the most part, I understand compile-time vs runtime quite well - in
particular, I don't find templates vs CTFE to be all that complicated once
you get into it. I find it to usually be straightforward and obvious, but
there are corner cases where it gets harder to understand, and in
particular, foreach with compile-time constructs gets weird enough that - to
me at least - it stops being straightforward. So, to a great extent, with
foreach and compile-time constructs, my understanding is primarily limited
to what I need to work in order to do the stuff that I do. And I'm obviously
not a D newbie. For newbies, the whole thing is going to be far harder to
understand, and for whatever reason, the fact that a function run with CTFE
can't use the template parameters beyond what can be done at runtime throws
off a lot of people.

- Jonathan M Davis




More information about the Digitalmars-d-learn mailing list