How does Circle's CTFE compare to D?

Ola Fosheim Grøstad ola.fosheim.grostad at
Sat Dec 4 10:00:17 UTC 2021

On Saturday, 4 December 2021 at 09:49:39 UTC, Ola Fosheim Grøstad 
> D's CTFE is somewhat more flexible than C++ constexpr, but C++ 
> constexpr/consteval also works as an interface specification, 
> meaning: if a function in a library is marked as compile time 
> then you can rely on it for the future and across platforms.

Just a simple example to make this obvious, let's say you use a 
matrix library that in a later is optimized so that it uses 
cpuid() to detect the CPU type. If you CTFE this you end up 
getting the CPU type of the machine the program was compiled on! 
Not what you wanted. There are many functions that are platform 
dependent, so general CTFE is not possible for a system level 
programming language.

More information about the Digitalmars-d mailing list