I've been pondering over this idea for a few weeks. What about
functions/methods that are built and ran at compile time.
Admittedly this sounds a bit like pre-processing, but it's not.
If the compiler must allocate memory which would probably be the
case for any classes (except those qualified with auto), something
needs to be done at run-time (allocating the memory for the object)
and I think that otherwise it might be complicate to implement...
Also, if the compiler can always do something at compile time,
why sometime it should be done at run-time. The compiler
should then simply compute the tradeoff (size, performance,..)
and do it the better way...
Of course it would require memory, but there are a few problems with
doing it at run-time.
I was thinking about that also. Parhaps the compile part need not
be tied to the function. Parhaps it should be tied to the call like:
Picture something = compile(loadBMP("mypicture.bmp"));
This can be cool for function like sin, cos and the like... but I
think it will almost never applies otherwise as I think it is not
possible to easily implement it so that arbitrary code can be run
at compile-time...
Maybe the best would be to have no keyword and the compiler
decide itself what it does at compile time and will issues an
error if we try to uses at compile-time a function that can be
used only at run-time... In debug builds, probably we will
want everything to be done at run-time except in the case
where a function is used at a place where a compile-time
call is required (for example an integer template argument).
I think compile time functions would be something that would be applied
near the end of a programs development cycle, as it could increase
compile times for debug mode.