Administrator
|
In general you don't want producers of boolean values to be allowed to produce any nonzero value and call it good.
A real good example of why this is so can be had with the ctype library in C. For performance reasons, functions such as isupper() return a 0 if False and something other than zero if true. So now let's assume that you want to do something if two characters are either both uppercase or both not uppercase. You realize that this could be written as
if (isupper(x) == isupper(y)) doSomething();
and you discover that most of the time when x and y are both uppercase letters is doesn't do the something.
Why not?
Because isupper(x) is returning 70 while isupper(y) is returning 82 and since 70 does not equal 82, the expression is False.
And, yes, things would be easier if the Hack had direct access to the program counter. Things would also be easier if the Hack had a barrel shifter, or this, or that, or about twenty other things. But that's not the framework that the Hack and the N2T project are coming from.
|