Sorting in D Blog Post Review Request
Jonathan M Davis via Digitalmars-d
digitalmars-d at puremagic.com
Sun Jun 4 15:55:40 PDT 2017
On Sunday, June 04, 2017 19:16:09 ag0aep6g via Digitalmars-d wrote:
> On 06/04/2017 06:07 PM, Mike Parker wrote:
> > https://gist.github.com/mdparker/51599471b5f19fe05ff01ca95b34d453
>
> From there: "What it boils down to is this: if a function *can* be
> executed at compile time, it *will* be."
>
> I think that gives the wrong impression. We regularly have newcomers in
> D.learn who expect CTFE to happen where it doesn't. They have a function
> call with all compile-time constants, and they expect it to be handled
> by CTFE. They think that the call *can* be evaluated at compile time, so
> it *will* be. But that's not how it works. CTFE only kicks in when the
> destination *requires* a compile-time constant.
Yeah, the compiler doesn't care at all about whether a function can be
called during CTFE until it actually attempts it, and it's only going to
attempt it in a context where the result _must_ be known at compile-time,
whereas that line implies that the compiler calls functions at compile-time
whenever it can, which would have a _very_ different effect.
- Jonathan M Davis
More information about the Digitalmars-d
mailing list