Non compile time evaluation for initializers
Reiner Pope
some at address.com
Fri Oct 26 05:47:02 PDT 2007
Max Samukha wrote:
> On Fri, 26 Oct 2007 10:52:25 +0200, Lutger
> <lutger.blijdestijn at gmail.com> wrote:
>
>> Lutger wrote:
>>> Janice Caron wrote:
>> ...
>>> Suppose this is implemented, then how can you achieve constant folding
>>> with CTFE in initializers? Since it is not a compile time context
>>> anymore, all functions that substitue y will be evaluated at runtime.
>> Nevermind, I responded too soon and overlooked the proviso that it's
>> only rewritten when it doesn't compile, sorry.
>
> Then if a compile time function is messed up in a way that makes it
> unevaluatable at compile time, it would be silently used at run-time,
> which is not desired?
There are plenty of other ways to force compile-time evaluation. I use
const int x = ctfeFunction();
much more than
// global namespace
int x = ctfeFunction();
I wouldn't have any objection to keeping const meaning ctfe-evaluated,
but global non-consts may be postponed till runtime.
-- Reiner
More information about the Digitalmars-d
mailing list