0

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"
treaz
  • 508
  • 2
  • 6
  • 14
  • Going to need some more information here; when I run your exact code in my Io interpreter, I get the expected result. Prints, then returns the string it printed for both println calls. If you're referring to the `0x123456` bits, those will always be different for different runs of the interpreter (i.e., REPL vs code, or REPL vs REPL, or code vs code) – jer Aug 23 '19 at 21:56
  • yes @jer I'm referring to the bits Matrix_0x40f210. I understand that for REPL vs code they're going to be different. My question is why are they not different where I run the code 'matrix1 proto println; matrix2 proto println' – treaz Aug 25 '19 at 12:12

0 Answers0