peterzheng98/Compiler-2020

Can int[] compare equality with int[]?

Closed this issue · 3 comments

It's not explicitly mentioned.

In my opinion, the array should be able to compare equality with the arrays of the same base type and dimension, since it can be assigned.

No, we can not compare two arrays. When assigning an array a to an array b, we are actually redirecting a pointer. On the other hand, comparing the underlying pointers makes little sense.

But without it we can't actually determine if two arrays point to same content in Mxstar.

Well, we try to keep Mx* simple so that students can spend more time on the backend. Hence, we prefer not to add this feature as, in my opinion, it is rarely useful.

Meanwhile, if someday this feature is gonna to be added, I believe it should be done by introducing a new builtin function so that it can be consistent with the behavior of string comparison.