On 5/01/12 10:17 PM, Iain Buclaw wrote:
On 5 January 2012 22:11, Manu<turkey...@gmail.com>  wrote:
So regarding my assumptions about translating the D front end expressions to
GCC? Is that all simpler than I imagine?
Do you think GDC generates optimal code comparable to C code?

What about pure functions, can you make good on optimisations like caching
results of pure functions, moving them outside loops, etc?



I think you are confusing the pure with memoization.  I could be wrong
however... :)


I think Manu is right:

void foo(int x)
{
    int[10] a;
    foreach (ref e; a)
        e = bar(x);
}

If bar is pure then you can safely transform this into:

void foo(int x)
{
    int[10] a;
    auto barx = bar(x);
    foreach (ref e; a)
        e = barx;
}

Reply via email to