CTFE Status 2

H. S. Teoh via Digitalmars-d digitalmars-d at puremagic.com
Wed Apr 5 09:06:39 PDT 2017


On Wed, Apr 05, 2017 at 11:20:28AM +0000, Yuxuan Shui via Digitalmars-d wrote:
> On Sunday, 2 April 2017 at 04:34:34 UTC, H. S. Teoh wrote:
> > On Sat, Apr 01, 2017 at 05:06:14PM +0000, Inquie via Digitalmars-d
> > wrote: [...]
> > > How far off until newCTFE is usable to compile the majority of
> > > templates out there?
> > 
> > CTFE and templates are two separate things. You may want to read
> > this (draft) article to get a better understanding of how they fit
> > together:
> > 
> > 	https://wiki.dlang.org/User:Quickfur/Compile-time_vs._compile-time
> > 
> > 
> > T
> 
> CTFE and template expansion might be more tangled than you thought.
> 
> For example, you do have access to CTFE during template expansion:
> http://forum.dlang.org/thread/yaekhryalyxyooaiuakj@forum.dlang.org

Did you read the entire article?

There is an entire section dedicated to interleaving of CTFE and
templates.  And no, you still cannot run CTFE on the same part of the
AST that is being template-expanded. But you *can* run CTFE on a subtree
that has already been fully expanded.

And no, the forum post you linked to has nothing to do with CTFE. The
so-called "static foreach" is unrolled at AST expansion time, and is not
run through CTFE at all (unless later on you call the expanded
function at "compile-time"). And is() expressions are also not CTFE,
they are also evaluated at AST expansion time.

Read the entire article first. ;-)


T

-- 
Guns don't kill people. Bullets do.


More information about the Digitalmars-d mailing list