Closed avivace closed 3 years ago
Is there any reason for this besides "I know Python and C"?
In order to pick the right one, is there an advantage of one over the other?
==
for equality and !=
for inequality=
for equality and <>
for inequalityI'd say that =
is the universally agreed symbol for equality, and since this is pseudocode, the tokenization/parsing ambiguity that caused ==
to be invented is not at all relevant. As for inequality, why not just use ≠
? Are we trying to support browsers from 1999 that don't support Unicode?
In papers with pseudocode I've sometimes seen math-standard =
and ≠
for equality/inequality, with ←
for assignment (as in sum ← 2 + 2
).
Is there any reason for this besides "I know Python and C"?
I don't have a strong opinion on that, I just want to set a standard rule to follow.
I tought maybe following a language syntax gives a more "familiar" look to the pseudocode? Are there examples of people writing pseudocode with ≠
?
≠ is mathematical notation that everyone knows and understands; it's (hopefully) taught in primary school. Same with =. I don't have any pseudocode examples at hand (using that syntax or any other), but it's certainly common. After all, pseudocode is not code.
Arguably C operators would also be okay since it's similarly low-level and snippets of it map well to asm. Like ld a, [hli]
being a = *hl++
.
But yes, there's plenty of pseudocode that uses ≠ and other Unicode: https://en.wikipedia.org/wiki/Pseudocode#Mathematical_style_pseudocode
Someone unfamiliar with C wouldn't know if that mapped to *(hl ++)
(as it does) or (*hl) ++
. That's generally not too great.
Especially because those correspond almost perfectly to the instructions ld a, [hl+]
and inc [hl]
.
How about:
References: http://www.cs.cornell.edu/courses/cs482/2003su/handouts/pseudocode.pdf , https://blog.usejournal.com/how-to-write-pseudocode-a-beginners-guide-29956242698, https://cs.wmich.edu/gupta/teaching/cs3310/sp18cs3310web/lecture%20notes%20cs3310/PseudocodeBasics.pdf, https://en.wikipedia.org/wiki/Pseudocode#Mathematical_style_pseudocode
/, mod
maybe ÷ and % instead?
I'm not a fan of % because it's also used for percentages.
/, mod
maybe ÷ and % instead?
÷ is okay, but what's wrong with /
?
/
is standard (see: fractions), so I see no issues with it.
Also ÷ can be hard to distinguish from +.
Added to the Pan Docs document style guide: https://github.com/gbdev/pandocs/wiki/Document-Style
There's still some syntax from the BASIC era (
<>
for!=
, ..).Pseudocode syntax should be standardized to use Python/C style