|
|
|
|
|
by nextaccountic
1778 days ago
|
|
> BTW, D is the first language of its type (curly brace static compilation) to be able to execute arbitrary code at compile time. It started as kind of "let's see what happens if I implement this", and it spawned an explosion of creativity. It has since been adopted by other languages. I don't know much about D compile time evaluation. How is it better than macros/templates? Also, what do you think about Haskell's and Rust's approach of generics with typeclass/trait bounds? |
|
CTFE isn't better than templates, it's a completely different tool. CTFE computes a result at compile time as though you had written a literal in the source code. Templates generate blocks of specialized code on the fly based on various parameters (typically types). They solve different problems.