Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Why does it need the D runtime to set a variable once? This seems very complicated.


I suppose that this is needed if you want to guarantee that all the constructors that are executed before main() are executed in a certain order.

I have not searched the latest versions of the C++ standard to see if anything has changed, but in the older versions of C++ it was impossible to ensure that the global constructors will be executed in a certain order (to be able to satisfy dependencies between them).

For static variables that only have initial values taken from the executable file, without initialization code, I assume that something like this is not necessary.


Still the same in regards to C++.


To be honest, I'm not entirely sure of the technical reason:

https://forum.dlang.org/post/sgiyhdnpdyxvigwtrfqk@forum.dlan...




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: