Open m-ender opened 7 years ago
I'll leave it to Chris to tell you what the spec was intended to mean, but it's worth mentioning that most Funge-98 interpreters work the same way. I've tested this on PyFunge, CCBI, Fungi, cfunge, rcfunge, and Befungius, and they all treat 0k
as skipping the next instruction, and 1k
as repeating the instruction twice.
That said, there was a Funge-108/109 spec floating around for a while in which the k
behaviour was changed to work the way you expected it would (i.e. 1k
only executes the following instruction once). However cfunge is the only interpreter I'm aware of that supports that option (rcfunge has some 108 features, but not that).
The iterate command
k
seems to treat0
specially. In particular, I'm observing the following behaviour:0
, the next instruction is skipped.n
), the next instruction is executedn
times with IP at the current position. Then the IP advances and the next command is executed again at the position of that command. That means if I do something like3k.
, I'll actually print 4 numbers. In particular, it's not possible to execute a command only once usingk
, unless it's some sort of direction changing or source code modifying command.I'm not sure whether this is the way it was intended, but the specification (looking at this document: https://github.com/catseye/Funge-98/blob/master/doc/funge98.markdown) doesn't mention that
0
is treated differently from other inputs. It mentions that zero would skip the next instruction entirely, but I had assumed that this means argument1
would result in it being executed exactly once.