1
General / Re: Multidimensional arrays as parameters
« Last post by Kays on Today at 07:36:57 pm »Dynamic arrays are reference counted. After invocation of setLength it is guaranteed that the reference count (of the variable you passed to setLength) is 1. That means using setLength you yourself always create an independent copy inside your routines.
In P3 you cannot invoke setLength directly on M because setLength decreases the reference count in the other previous version of M, i. e. an implicit write operation which is forbidden by const.
A var parameter can be implemented as a value parameter entailing an implicit writeback operation once the routine finishes. This writeback is essentially A_in_main := M_in_P2, i. e. simply copying pointer values (including implicit reference count adjustments). There is no “deep copy” involved.
In P3 you cannot invoke setLength directly on M because setLength decreases the reference count in the other previous version of M, i. e. an implicit write operation which is forbidden by const.
A var parameter can be implemented as a value parameter entailing an implicit writeback operation once the routine finishes. This writeback is essentially A_in_main := M_in_P2, i. e. simply copying pointer values (including implicit reference count adjustments). There is no “deep copy” involved.