4 ms·
This is brilliant! Equivalent, in its way, to C++ template metaprogramming. It was cheeky to do a Forth instead of an ML. The traditional way to demonstrate TC
by ncmncm 6y ago
This is brilliant! Equivalent, in its way, to C++ template metaprogramming. It was cheeky to do a Forth instead of an ML. The traditional way to demonstrate TC is by sieving primes at compile time.
C++ is actively replacing its compile-time ML with core language features, but isn't there yet. Still, it has been many years since I needed to code any of my own TMP.
- bonzini 6y agoSort of, arithmetic is implemented (through the trait-eval crate) from the Peano axioms. Probably it is not very fast, even in comparison to C++ standards.
- Ashymad 6y agoIndeed, could possibly be sped up by using typenum[1] instead of trait-eval, as it is not Peano axioms based. [1] https://docs.rs/typenum/ https://docs.rs/typenum/