[fpc-pascal] How does FPC perform in the FASTEST Computer Language Race

Jonas Maebe jonas at freepascal.org
Sat Jul 10 19:18:28 CEST 2021


On 10/07/2021 18:46, Ryan Joseph via fpc-pascal wrote:
> Here's the C++ version that won. Looks like the magic comes from constexpr, which I don't understand very well in C++ except that it's a constant expression. Can anyone explain how constexpr works here?

A constexpr function means that it must be computable at compile time if
all of its arguments are also constexpr.

It's also basically explained at
https://github.com/PlummersSoftwareLLC/Primes/tree/drag-race/PrimeCPP/solution_3
: "Deviation: It does use the base algorithm but due to compile time
optimization, a lot of the actual calculation does not happen at runtime"

and

"Note: this solution is limited to numbers up to around 50,000,000
(stack size limit on Mac OS it seems)." (due to the compile-time evaluation)


Jonas


More information about the fpc-pascal mailing list