What happens in Befunge if the execution reaches the limits of the program?

306 views Asked by At

I couldn't find an answer to this question... Is there a "periodic boundary condition"? I.e. does the execution continue on the opposite site? Or is it illegal that the execution leaves the program?

1

There are 1 answers

3
luser droog On BEST ANSWER

from http://en.wikipedia.org/wiki/Befunge

The Befunge-93 specification restricts each valid program to a grid of 80 instructions horizontally by 25 instructions vertically. Program execution which exceeds these limits "wraps around" to a corresponding point on the other side of the grid; a Befunge program is in this manner topologically equivalent to a torus.

So, for "classic" Befunge, yes, it wraps. But later developments made it not-so-simple.

Since a Befunge-93 program can only have a single stack and its storage array is bounded, the Befunge-93 language is, unlike most machine languages, not Turing-complete (however, it has been shown that Befunge-93 is Turing Complete with unbounded stack word size).[3] The later Funge-98 specification provides Turing-completeness by removing the size restrictions on the program; rather than wrapping around at a fixed limit, the movement of a Funge-98 instruction pointer follows a model dubbed "Lahey-space" after its originator, Chris Lahey. In this model, the grid behaves like a torus of finite size with respect to wrapping, while still allowing itself to be extended indefinitely.