3 ms·
OP here. One interesting thing about FOCAL is that * has higher precedence than /. So in Lunar Lander, M*G/Z*K is what mathematicians and other languages woul
by martincmartin 2y ago
OP here. One interesting thing about FOCAL is that * has higher precedence than /. So in Lunar Lander, M*G/Z*K is what mathematicians and other languages would write M*G/(Z*K). I did a double take when I first saw that. :) As the Wikipedia article says, "This can cause subtle errors when converting FOCAL source code to other systems."
Also, the IF syntax is a little limiting and hard to read, although I suppose programmers would get used to it.
- pbhjpbhj 2y agoYour code got munged, use backslash to escape * (otherwise it starts a span of italicised text), or use four leading blanks for code blocks (in which escaping is usually not needed): M*G/Z*K I think you meant, the above and M*G/(Z*K) respectively.
- martincmartin 2y agoThanks. Fixed!
- jprete 2y agoThat's surprising from today's perspective, but when I imagine the thought process, it seems reasonable, especially for math and science purposes where multiplication and division operators usually get grouped into a series of multiplications above the division bar, and a series of multiplications below it.
- martincmartin 2y agoTrue. + also has higher precedence than -, so that a - b + c means a - (b + c).
- MarkusQ 2y agoAh, the old My Dear Aunt Sally vs. My Dear Aunt Sally debate. :)
- omoikane 2y agoAnother curious feature is that the labels appears to be floating point, as in "G 5.9" appears to transfer control to line starting at "05.90".
- LegionMammal978 2y agoThey aren't actually floating-point: each label is a pair of numbers, the first denoting the group and the second denoting the line within that group. The groups have no semantic importance, they are only for organization.
- LegionMammal978 2y agoActually, I was mistaken. The line numbers aren't even numbers, so much as digit pairs, given how one-digit labels take the first digit. And the "DO" command takes a group number, runs each line within the group, then returns after the end of the group. So each group can effectively act as a subroutine. (In this particular game, this can be seen in groups 6 and 9.)