
Compiling at Compile Time - luu
https://blog.veitheller.de/Compiling_at_Compile_Time.html
======
ephaeton
"At runtime, we could use cond for that, but since that is a macro as well, we
can’t use it at compile time."

D'oh. Who writes a lisp with macros where you can't use macros at macro-
expansion-time??

------
sansnomme
In Nim:

[https://howistart.org/posts/nim/1/](https://howistart.org/posts/nim/1/)

~~~
jeff_ciesielski
I wrote something similar a while back (also in nim):
[https://github.com/Jeff-Ciesielski/synesthesia](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.

------
windsurfer
This is horrifying and awesome.

------
rgoulter
See also: Compile-Time Snake [https://github.com/mattbierner/STT-C-Compile-
Time-Snake](https://github.com/mattbierner/STT-C-Compile-Time-Snake)

------
gnulinux
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.

------
w-m
And then there's this compile-time C compiler implemented as C++14 constant
expressions of course:

[https://github.com/keiichiw/constexpr-8cc](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..

~~~
lonelappde
That would require emulating all syscalls (side-effects) to get a mock of the
Real World inside the compile time environment.

~~~
enriquto
the path to glory is a long and arduous one

------
rurban
Only lisp macros, no magic

~~~
m463
in lisp lambda is the definition of magic

~~~
rurban
no, macros are

------
hr0m
In D with D "mixins":
[https://github.com/m3m0ry/drainfuck](https://github.com/m3m0ry/drainfuck)

~~~
Doxin
You might be better off linking directly to the source code:
[https://github.com/m3m0ry/drainfuck/blob/master/source/app.d](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.

------
keyle
Posts like these is why I read HN religiously!

