There is an extended version of bf which has a goto
instruction, ?
.
I know that, in theory, it should be possible to simulate a goto in the classic 8 instruction version of bf. How can I do that in practice? Is there an existing bf goto pattern or algorithm? Is there a way to transform a goto ?
instruction into a version of bf without goto ?
instruction?
There are no easy or trivial ways to do this that I know of. This is one of the main challenges in compiling a language into Brainfuck.
It is of course possible in theory, as you said, but it requires you to structure your code in a very disciplined manner by implementing a stack or heap or some similar data structure.
The project C2BF is a partial compiler from C to Brainfuck that does exactly this. It emulates a stack by interpreting the Brainfuck cells into a repeating pattern of five, namely,
If you are interested in more specific implementation details of doing this sort of thing, you might be interested in looking at this description for BrainFix, which describes more fully how to do simple flow and memory control.