It seems pure ain't so pure after all

Tommi tommitissari at hotmail.com
Mon Oct 1 10:46:16 PDT 2012


On Monday, 1 October 2012 at 08:04:49 UTC, Jonathan M Davis wrote:
> And you _can't_ determine ahead of time which functions can be 
> safely executed at compile time either, because that's an
> instance of the halting problem.

I don't understand (I did read what "halting problem" means just 
now, but I still don't understand). If there was no __ctfe 
variable, and thus a guarantee that all functions do the same 
thing at compile-time and run-time, couldn't the compiler just 
try aggressively to execute all function calls at compile-time? 
Obviously it wouldn't bother trying CTFE for function calls that 
had arguments which weren't evaluable at compile-time. Nor would 
it bother with functions that it knows have memory allocations or 
other limitations of CTFE.

If not a compiler flag, then it could be a function attribute. 
Just like c++ function attribute constexpr, which guarantees that 
the function executes at compile time given you provide it with 
compile-time evaluable arguments (and there are limitations to 
what the function can do). Why wouldn't this attribute be 
possible with D?


More information about the Digitalmars-d mailing list