LDC 1.18.0-beta1

Ivan Butygin ivan.butygin at gmail.com
Mon Sep 23 19:40:13 UTC 2019

On Monday, 23 September 2019 at 12:22:47 UTC, Martin Tschierschke 

> Can you please give (again?) a link or a more detailed 
> description of the JIT, explaining some use cases?


@dynamicCompile attribute allow you to delay final function 
optimization to runtime. You mark any function (virtual functions 
and lambdas are also supported) with @dynamicCompile and then 
call compileDynamicCode during runtime to finally optimize and 
compile function to native code, using host processor instruction 

There is also jit bind which works much like c++ bind but also 
non-placeholder params are treated and optimized as constants by 

@dynamicCompileEmit int foo(int a, int b, int c, bool flag)
   if (flag)
     // this check and code will be removed by optimizer
   return a + b + c; // this will be optimized to 40 + c

auto f = bind(&foo, 30, 10, placeholder, false);
int delegate(int) d = f.toDelegate();


assert(f(2) == 42);
assert(d(2) == 42);


More information about the Digitalmars-d-announce mailing list