Philippe Mori wrote:
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.
1) Efficiency, if it's done at compile time, the load time is reduced, for the user. Also, the memory doesn't need to be dynamic as it would if it was loaded at run-time.
2) You can compact everything into one file.
3) A program may be run many times, but it is only ever compiled once.  This is useful for things such as type information ect...
4) It allows you to customise what is compiled, and how it is compiled.
5) Compile time checking.

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.

  
Now that makes more sense, and could be used with the library
only policy I suggest.
    

I haven't read about that...

  
I was just saying that only libraries could be used at compile time since they are already compiled. It's be no more effort for the compiler then just finding the program execution point in the library, and passing in the correct parameters.