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.
    

I like the idea too... since it would help make metaprogramming
easier by allowing to do some things using function syntax...

    compile int matrix_size(int a, int b) { return a * b; }

    double [matrix_size(4, 5)] my_array;

What I'm not sure it weither we should allows arbitrary code
in those functions or if we should only allows constant expression
evaluation (this might include math function like sin).

    const double sin30 = sin(deg2rad(30));

I would think that a compile time function would need to have
a return value that is a constant (or maybe a global object).
The function must be evaluable at compile-time and have no
side-effect...

Here we see that we would like to have functions that can be
both compile-time or run-time... Will this cause a debate like
we have seen in C++ on the utility of inline... Would we need
another modifier to say either compile or run-time (we were
having a similar question for static vs run-time assert)?

  

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"));

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

  
Yet another use would be for more advanced compile time
checking ie like an advanced static assert.
    

like the following:

    template (T)    // T should be integral type
    compile same_size(T t1, T t2)
    {
        static_assert(t1 == t2);
    }

  
Yeah, although if it was compile time, assert would act like static_assert.

In that case, we would like the compiler to give information
on where the function was called and the argument that were
passed (same thing for any other compilor error or warning).

  
If you had a stack trace, it wouldn't be much of a problem.

Again, one thing that I think would be great with that is
automatic template instanciation.

    template (T)
    compile T fact(T t)
    {
        return t > 1 ? fact(t -1) : 1;
    }

    int f = fact(4);    // f = 4 * 3 * 2 * 1

  
-Anderson