It seems pure ain't so pure after all

Jonathan M Davis jmdavisProg at gmx.com
Mon Oct 1 01:04:43 PDT 2012


On Monday, October 01, 2012 09:46:43 Tommi wrote:
> I'll have to consider all functions potentially schizophrenic
> then. They might do one thing at compile-time and another at
> run-time.

That's only the case if they're buggy, so that's pretty much the same as 
considering all functions potentially buggy.

> I was going to make a feature request to add a compiler flag for
> making more functions execute at compile-time than those which
> the compiler *has* to. But this __ctfe thing renders that
> impossible.

I have no idea how you could possibly use a compiler flag for that, whether 
__ctfe or not. It really doesn't make sense to try and make functions in 
general run at compile time. Most of the time, functions need to be run at 
runtime, otherwise you wouldn't even need to generate an executable, just a 
result. 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. So, it really doesn't make sense to have the compiler trying to 
evaluate functions at compile time when it hasn't been explicitly told to.

And it works just fine to assign the result of a function call to enum if you 
want a specific function call to be executed at compile time, so I really don't 
think that this is an issue anyway.

- Jonathan M Davis


More information about the Digitalmars-d mailing list