What is the philosophy behind arrays not being copied when assigned to another variable?

Two things.

  1. There is a previous answer of mine that helps to internalize the memory model. On boxes vs labels: Is it appropriate to say a variable is a label or box? - #19 by Henrique_Becker
  2. In C, you can have static-sized arrays and (mutable) structs that when assigned to a variable will copy the value to the variable because the variable is kinda guaranteed to be a memory space. However, any array with dimensions only known at runtime (and a lot of structs that have pointers stored) will have no-copy/shallow-copy problems a lot of times.
6 Likes