Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

D arbitrary code at compile time

Tags:

d

dmd

ctfe

I've heard D can execute arbitrary user code at compile time. Is this true? Could someone give an example (particularly when compilation never terminates)? What this feature is for? Also if that's so is there a way to disable this with some compiler option (compiler is dmd)?

like image 310
ren Avatar asked May 09 '26 06:05

ren


1 Answers

Yes, it's partially true. D has compile time function execution, i.e. it has the ability of executing functions at compile time. But such functions are required to be both portable and free of side effects.

You will find an in-depth explanation in the official documentation of the D language.

like image 181
Roberto Reale Avatar answered May 11 '26 16:05

Roberto Reale



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!