D's treatment of values versus side-effect free nullary functions
Walter Bright
newshound2 at digitalmars.com
Fri Jul 23 02:45:25 PDT 2010
Andrei Alexandrescu wrote:
> Walter Bright wrote:
>> Don wrote:
>>> While running the semantic on each function body, the compiler could
>>> fairly easily check to see if the function is CTFEable. (The main
>>> complication is that it has to guess about how many iterations are
>>> performed in loops). Then, when a CTFEable function is called with
>>> compile-time constants as arguments, it could run CTFE on it, even if
>>> it is not mandatory.
>>
>> I think this is the halting problem, and is insoluble.
>
> On what basis?
Trying to determine by static analysis if a function would evaluate within a
"reasonable" amount of time, or even if it would finish at all.
So let's suppose the compiler just attempts CTFE on those functions anyway, with
a timeout if they take too long. Suddenly we've just thrown all the compiler
performance out the window.
More information about the Digitalmars-d
mailing list