Re:Compiling at Compile Time
by gnulinux on Thursday November 07, 2019 @10:02PM
(#21479653)
Hah, remember doing this in C++ templates when I learned C++ metaprogramming is Turing complete, back in high school. Named my library yabi "yet another brainfuck implementation". Simpler times.
For people unfamiliar with D, a mixin is essentially equivalent to compile-time eval. you call mixin() with a string, that call then gets replaced with that string compiled as D code. Combine that with the fact that you can run arbitrary code at compile time in D and you get brainfuck-as-a-DSL in 27 lines of code.
Can be only months now, until somebody combines a constexpr compile-time C-to-WASM compiler with a constexpr compile-time WASM interpreter to run any software ever written, at compile time..
D'oh. Who writes a lisp with macros where you can't use macros at macro-expansion-time??
https://howistart.org/posts/nim/1/
When I stop being so darn busy, I do want to revisit my original project of doing the same thing for a FORTH derivative.
For people unfamiliar with D, a mixin is essentially equivalent to compile-time eval. you call mixin() with a string, that call then gets replaced with that string compiled as D code. Combine that with the fact that you can run arbitrary code at compile time in D and you get brainfuck-as-a-DSL in 27 lines of code.
https://github.com/keiichiw/constexpr-8cc
Can be only months now, until somebody combines a constexpr compile-time C-to-WASM compiler with a constexpr compile-time WASM interpreter to run any software ever written, at compile time..