catseye / Befunge-93

MIRROR of https://codeberg.org/catseye/Befunge-93 : The NEW reference distribution for Befunge-93!
https://catseye.tc/node/Befunge-93
Other
98 stars 9 forks source link

Limits for `p` operation #33

Open Jachdich opened 4 years ago

Jachdich commented 4 years ago

It is unclear from what I have read what the limits of the p operation are, e.g. this program:

99*:*66p

Does it store 6561 or whatever (signed char)6561 is?

j4james commented 4 years ago

The reference interpreter will store the value as a signed char, i.e. -95, but there is a wide variation in behaviour by other interpreters. Some use signed values, some use unsigned, and they can range from 8 bits to unbounded.

Jachdich commented 4 years ago

Thanks for the clarification. I'm guessing it's not against the specification to use a signed long to store your code? (That's what I've done in my interpreter)

j4james commented 4 years ago

The specification just refers to the playfield cells as "characters", which leaves some room for interpretation, but a signed long seems a bit of a stretch. Also, speaking as a Befunge programmer, I personally prefer interpreters that match the behaviour of the reference interpreter exactly, since it makes it easier to write portable code.

That said, nobody is going to stop you doing things your own way. Plenty of other interpreters have done the same thing. Just bear in mind that your interpreter may then not be able to run some Befunge code that relies on the reference behaviour. As a compromise, you could always have an option in your interpreter to be more standard compliant.

Jachdich commented 4 years ago

That's a good idea. I'll add a command line switch to disable all custom features (I've added a few instructions, such as a primitive jump that I'll also disable).