The algorithmic description of same-line wrapping can be described as
backtrack wrapping. It is more of interest to Funge interpreter
implementers than Funge programmers. However, it does describe exactly
how the wrapping acts in terms that a programmer can understand, so we
will include it here.
When the IP attempts to travel into the whitespace between the code and
the end of known, addressable space, it backtracks. This means that its
delta is reversed and it ignores (skips over without executing) all
instructions. Travelling thus, it finds the other 'edge' of code when
there is again nothing but whitespace in front of it. It is reflected
180 degrees once more (to restore its original delta) and stops ignoring
instructions. Execution then resumes normally - the wrap is complete.
It is easy to see at this point that the IP remains on the same line:
thus the name. (Also note that this never takes any ticks in regards
to multithreading, as would be expected from any wrapping process.)
This above is probably most confusing description I've ever read in a spec. And I've read quite a few specs in my life. Please help me understand it and may be improve it, so it's more accessible for everyone.
First of all it is not clear what is "whitespace" above. This word appears two times in the quoted section, and never again before or after in the specification. Without other guidance, we should assume conventional meaning, which is usually a character that represent horizontal or vertical space. In the context of the spec, my best guess, that this is a cell with a space character ASCII 32. If that's not the case, please clarify.
Next, "line" is mentioned in the quoted text, but I'm not sure how to connect this with the previous discussion of lines in the spec. My best guess is based on the following paragaph:
The source file begins at the origin of Funge-Space. Subsequent columns of characters increment the x coordinate, and subsequent lines increment the y coordinate (if one is present) and reset the x coordinate to zero. Subsequent lines in Unefunge are simply appended to the first, and the end of the source file indicates the end of the (single) line.
So I'm assuming that a line, is everything that has the same y coordinate as IP. If this is wrong, please clarify.
When the IP attempts to travel into the whitespace between the code and the end of known, addressable space, it backtracks.
Let's try to decompose this a bit. When IP "travels" it travels from the current node to the next node as specified by the delta. That next node contains a cell which may or may not contain a whitespace. The specification either assumes that it certainly does, or limits the description to the cases when it does. As far as I can see it, the prime case for wrapping, is when there next node does not exist at all because we reached the edge of addressable space. Similarly, it's not clear why would we want to wrap, if we has not reached the end of addressable space yet, on a white space. May be this too could be clarified?
It is easy to see at this point that the IP remains on the same line: thus the name.
This sound as complete non-sequitur. I can see why this may be true if the delta point along the line IP is currently on, but in any other case I cannot see how this could be true.
I feel that this section may benefit from better definition of terms it's using, and simply from better wording. Also it is very hard to see what the diagram is trying to demonstrate. May be a few words tying it to the text somehow could help?
And a small unrelated to the above suggestion: r
seems to refer to "reverse" is some parts of the document and to "reflect" in others. I believe that consistency here, or a clear explanation what the relationship between "reflect" and "reverse" is would make the document less confusing. If "reflect" and "reverse" is the same thing, I would suggest choosing a single term (I would vote for "reverse") and use it through the document, not just as the keyword for r
instruction, but as well for concepts explanation.