I’m completely in favor of disallowing truthy and falsey values, and I hope the core team is never swayed otherwise. Having said that, this claim caught my eye:
I teach an introductory programming course, and one of the concepts I introduce first is the “paper computer”. This is a computer that only exists on paper and runs by the user keeping track of its state using a pencil. My version has 16 words of code memory, 7 general purpose registers (R0
to R6
), a program counter (PC
) and five instructions:
STP
: stops executionSKP R#
:R# == 0 ? PC <- PC+2 : PC <- PC+1
JMP ##
:PC <- ##
ADD R#
:R# <- R#+1, PC <- PC+1
SUB R#
:R# <- R#-1, PC <- PC+1
This instruction set is Turing complete, so it allows me to define “computational thinking” as “make this machine solve your problem for you”. Anyway, the first exercise is to write a program to add R0
to R1
and store the result in R2
.
I’m wondering, can this problem be solved if the meaning of SKP R#
is changed to “skip if even”? After a few minutes of thought, I’m leaning towards “no”, but I’d like to be proven wrong. If it can’t be done, it’d mean that there’s something fundamental in jz
and jnz
that is not shared by je
and jo
.