[NTLK] NEWT/0 set-aref bug

Simon Bell simonbell at me.com
Tue Dec 16 05:01:11 EST 2014


I don’t think the bug is in (or around) set-aref. Here is the code Newton generates:

begin
local A := [0, 0];
A[0] := 1;
A[1] := 2;
Print("Hello world!");
end

<function, 0 args, #04C4DE21>
   0: push-constant 0
   1: push-constant 0
   2: push 'array
   3: make-array 2
   4: set-var 3 [A]
   5: push-constant nil
   6: get-var 3 [A]
   7: push-constant 0
   8: push-constant 1
   9: freq-func 3 [setAref/3]
  10: get-var 3 [A]
  11: push-constant 1
  12: push-constant 2
  15: freq-func 3 [setAref/3]
  16: push "Hello world!"
  17: push 'Print
  18: call 1
  19: return
"Hello world!"
nil

setRef leaves the value it set on the stack as it should according to the spec. However, the Newton interpreter unwinds the stack on function return to leave just the return value on it. (Any exception handlers are also unstacked at this point.) I don’t know what NEWT/0 does, but I believe that is the correct approach.

Simon


More information about the NewtonTalk mailing list