Clone behavior diffent in REPL vs script

36 Views Asked by At

I have this piece of code that behaves differently in the io REPL vs running it as a script (i.e. io matrix_clone_test.io). To be specific:

  • in the REPL, matrix1 and matrix2 point to different objects (different ids: Matrix_0x504b80, Matrix_0x42edd0)
  • when executing the script, matrix1 and matrix2 point to the same object (same ids: Matrix_0x40f210, Matrix_0x40f210)

I was expecting in both cases to see different objects resulting from Matrix clone. What am I missing?

Code snippet

Matrix := Object clone
matrix1 := Matrix clone
matrix2 := Matrix clone
matrix1 proto println
matrix2 proto println

Console output

Io> Matrix := Object clone
==>  Matrix_0x739da0:
  type             = "Matrix"

Io> matrix1 := Matrix clone
==>  Matrix_0x504b80:

Io> matrix2 := Matrix clone
==>  Matrix_0x42edd0:
[println code excluded for brevity]

Script execution

 Matrix_0x40f210:
  type             = "Matrix"

 Matrix_0x40f210:
  type             = "Matrix"
0

There are 0 best solutions below