GNOME Bugzilla – Bug 650663
Require explicit copy() method for arrays
Last modified: 2018-03-21 13:28:37 UTC
Hello, compact classes actually need an explicit call to .copy() (if it exists) and recently copying delegates has been deprecated. I'd like to suggest for coherency to deprecated implicit array copy. I guess most of the time array copy is not wanted from a performance point of view, like in this case: int[] arr1; ... int[] arr2 = arr1; In this case arr1 is copied into arr2, this doesn't work anymore with delegates and compact classes, which are pretty similar to arrays. For this reason I'd like to deprecate this implicit copy in favor of calling a .copy() method on arrays: int[] arr2 = arr1.copy();
Yes, let's do this in the 0.13 cycle.
Do we have to add ArrayCopyMethod or we can do it like with SignalType?
Created attachment 192912 [details] [review] Deprecate implicit copy of arrays, use explicit copy method Fixes bug 650663.
Do we want to fix copying arrays for closure/coroutine first for consistency?
Created attachment 337947 [details] [review] Deprecate implicit copy of arrays, use explicit copy method Fixes bug 650663.
This would be nice to have! The patch still works fine with a minor tweak. The problem is the return-type of properties were "owned get" == "get" for arrays, so this need to be respected. public class Foo { // do not warn here public int[] a { owned get; set; } // warn here and suggest "owned get" public int[] b { get; set; } // do not warn here public unowned int[] c { get; set; } } void main () { int[] i = { 1, 2, 3, 4 }; // warn here var a = i; }
Created attachment 338093 [details] [review] Add explicit copy method for arrays
Comment on attachment 338093 [details] [review] Add explicit copy method for arrays commit d274caac1745465c50cfe14908452e0d024011f1 Author: Luca Bruno <lucabru@src.gnome.org> Date: Sat Jul 30 16:41:34 2011 +0200 Add explicit copy method for arrays
*** Bug 672752 has been marked as a duplicate of this bug. ***
Created attachment 359036 [details] [review] codegen: Deprecate implicit copy of arrays, use explicit copy method
Created attachment 359597 [details] [review] codegen: Deprecate implicit copy of arrays, use explicit copy method