Newton Formats, the document which describes, among other things, the Newton OS package format and provides a specification for a de facto standard NewtonScript virtual machine, contains a few errors. Here I provide corrections to them.
The lowest 4 bits of a character Ref are 0110, not 1010. If they were 1010, $\u0001
(0x16) would be indistinguishable from true
(0x1A).
The C code for the symbol hash function has a bug; it loops forever. It also assumes that long
is 32-bit (which the document acknowledges). Here is a simpler, correct, and more portable version (requires ctype.h and stdint.h):
uint32_t SymbolHash (char* Name)
{
uint32_t Result = 0;
while(*Name)
Result += toupper(*Name++);
return Result * 2654435769U;
}
The descriptions of the send and send-if-defined instructions say that name comes before receiver; it is actually the opposite.
The descripton of the resend-if-defined instruction does not specify the state of the stack before and after the instruction is executed. The state is the same as for the resend instruction.
The description of the divide instruction says:
If num2 is the integer zero, the exception |evt.ex.div0|
is thrown.
Apple's implementation ignores this rule and instead converts num2 to a real. This causes num1 to be converted to a real too, giving the result of positive or negative infinity.
NSM currently does the same.
An NSOF stream does not necessarily represent a directed acyclic graph. NSOF is perfectly capable of handling cycles; this is one of its advantages over other formats such as JSON.
In the NewtonScript code that generates the frame x, the slot named right should be named uchar instead.