Mike Farnsworth wrote:
Walter Bright Wrote:

Michael Farnsworth wrote:
The ldc guys tell me that they didn't include the llvm vector
intrinsics already because they were going to need either a
custom type in the frontend, or else the D2 fixed-size-arrays-as-value-types functionality. I might take a
stab at some of that in ldc in the future to see if I can get it
to work, but I'm not an expert in compilers by any stretch of the
imagination.
I think there's a lot of potential in this. Most languages lack
array operations, forcing the compiler into the bizarre task of
trying to reconstruct high level operations from low level ones to
then convert to array ops.

Can you elaborate a bit on what you mean?

Sure. Consider the code:

    for (int i = 0; i < 100; i++)
         array[i] = 0;

It takes a fair amount of work for a compiler to deduce "aha!" this code is intended to clear the array! The compiler then replaces the loop with:

     memset(array, 0, 100 * sizeof(array[0]));

In D, you can specify the array operation at a high level:

    array[0..100] = 0;

In other words, a language is supposed to represent high level concepts and the compiler breaks it down into low level ones supported by the machine. With vector operations, etc., the language supports only the low level operations and the compiler must reconstruct the high level operations supported by the machine.

This inversion of roles is bizarre.

Reply via email to