Hacker News new | past | comments | ask | show | jobs | submit login
Compiling at Compile Time (veitheller.de)
95 points by luu 5 days ago | hide | past | web | favorite | 15 comments





"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??



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.



This is horrifying and awesome.

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.

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


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


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.


Only lisp macros, no magic

in lisp lambda is the definition of magic

no, macros are

Posts like these is why I read HN religiously!



Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact

Search: