
Brainfuck interpreter written in the C preprocessor - pepsi_can
https://github.com/orangeduck/CPP_COMPLETE
======
kibwen
_"There has been much speculation on the turing completeness of the C
Preprocessor, but I believe this is the first demonstrative proof that the C
preprocessor is turing complete. This uses no GCC extensions and other than
the rules for macro evaluation the only 'features' it takes advantage of are
token pasting and variable argument macros."_

Can anyone confirm that this is really the first demonstrative proof of this
kind?

~~~
CJefferson
No.

It is well known that the C preprocessor is not turing complete. Looking in
[https://github.com/orangeduck/CPP_COMPLETE/blob/master/RECR....](https://github.com/orangeduck/CPP_COMPLETE/blob/master/RECR.h)
shows us this technique is not turing complete, as these functions define a
maximum recursion depth.

~~~
krenoten
It is impossible to implement a system without a de-facto recursion depth
limit.

~~~
asynchrony
Recursion depth limit is really a memory limit, so you just need someone to
come and install more RAM when you run out in order to obtain de facto
infinite memory, hence infinite recursion depth.

~~~
mistercow
Even that is not infinite because there is a limit to how much memory you can
address. You don't have to bring physical realities into it.

~~~
asynchrony
The system will just spontaneously update to the next power-of-two bits when
address space gets short. Problem solved.

~~~
mistercow
That would break binary compatibility with all existing programs, though. So I
guess the claim should be that it's impossible to implement a practically
useful system without a de-facto recursion depth limit.

------
JulianMorrison
Now all you need to do is implement COBOL in it, and the gate to hell will
open.

------
jrajav
He said it doesn't use any gcc extensions, but this still doesn't seem to work
with llvm-gcc or clang. :(

~~~
JoachimSchipper
I haven't tried this, but did you compile with the equivalent of -std=c99?

------
tsewlliw
If there's a recursion limit, can you not write a program that fails to
terminate?

~~~
mistercow
Well sure, but there's always a recursion limit of one kind or another.

~~~
JulianMorrison
All programs terminate at the heat death of the universe.

------
wheaties
Impressive. Massively impressive. Does this count towards your thesis in any
way? I'd hate the kind of effort this required to go to waste when PhDs sucks
the life out of your for 6-8 years (at least in the US.)

------
angeladur
Has anybody checked out [<http://www.ioccc.org/2001/herrmann1.hint>

