[4Walter&Andrei] D is 40 times slower. We need a new language feature!

9il via Digitalmars-d digitalmars-d at puremagic.com
Fri May 19 22:14:37 PDT 2017


On Saturday, 20 May 2017 at 03:50:31 UTC, rikki cattermole wrote:
> On 20/05/2017 4:24 AM, 9il wrote:
> snip
>> Looks like Rust macro system can do something similar.
>
> Just to confirm, in Rust is it calling a function to assign the 
> value?

I mean that Rust has macro system. I do not know if it can be 
used for indexing.

> E.g.
> ```D
> void opIndexAssign(T v, size_t j, size_t i);
> ```
>
> Because if the compiler is seeing a function call, it probably 
> won't attempt this optimization, but if its seeing a direct to 
> memory write, that's a different story.
>
> Also the compiler doesn't know if ``foo[i][j]`` is equal to 
> ``foo[i, j]``. So your proposed solution isn't valid.

Proposed solution is similar to mixins. Compiler do not need to 
know something. Compiler just need to replace `foo[i, j]` with 
its body like it is a mixin. All loop optimiation would be done 
by optimizer. See clang loop optimisation for more details.



More information about the Digitalmars-d mailing list