Compiling at Compile Time(blog.veitheller.de)
blog.veitheller.de
Compiling at Compile Time
https://blog.veitheller.de/Compiling_at_Compile_Time.html
9 comments
I wrote something similar a while back (also in nim):
https://github.com/Jeff-Ciesielski/synesthesia
When I stop being so darn busy, I do want to revisit my original project of doing the same thing for a FORTH derivative.
When I stop being so darn busy, I do want to revisit my original project of doing the same thing for a FORTH derivative.
This is horrifying and awesome.
See also: Compile-Time Snake
https://github.com/mattbierner/STT-C-Compile-Time-Snake
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.
In D with D "mixins": https://github.com/m3m0ry/drainfuck
You might be better off linking directly to the source code: https://github.com/m3m0ry/drainfuck/blob/master/source/app.d
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.
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.
And then there's this compile-time C compiler implemented as C++14 constant expressions of course:
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..
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..
That would require emulating all syscalls (side-effects) to get a mock of the Real World inside the compile time environment.
the path to glory is a long and arduous one
Posts like these is why I read HN religiously!
D'oh. Who writes a lisp with macros where you can't use macros at macro-expansion-time??