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

> Arbitrary compile time computation should be separated from the body of the program.

Here's some code that initializes an array at compile time with a non-trivial computation:

https://github.com/dlang/dmd/blob/master/src/dmd/backend/var...

This used to be initialized by a separate program that generated some .d files. It was nice to get rid of that. Even better, if you check the generated object file, there's no trace of the code used to generate the array - just the data for the array.



> > Precomputing values without I/O is conceptually just an advanced kind of compiler optimization, and that’s why Rust is basically seeking to make const fns only pure functions.

I agree that generating an array at compile time is perfectly fine. I was saying that I/O should be restricted in compile-time computation, which the person I was responding to made me believe was entirely unrestricted in compile-time computation in D.




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

Search: