[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Object copy function question


Thank you all for your answer, that confirm there is no magic function already present in Gambas to copy custom Class objects array.

It’s fine, I made mine for the specific Class object array I manipulate into my project.

I just wanted to be sure about the way to do because It took me few hours to find my bug related to the copy of Class object array. 

Olivier Cruilles


> Le 6 sept. 2024 à 04:56, Fabien Bodard <gambas.fr@xxxxxxxxx> a écrit :
> 
> You can speed up the copy by mixing the array.copy and self made copy for referenced types (object or arrays)
> 
> But remember that each object must have a self copy function because there is no way to make it automatically in all cases
>   
> 
> Le ven. 6 sept. 2024 à 00:54, Benoît Minisini <benoit.minisini@xxxxxxxxxxxxxxxx <mailto:benoit.minisini@xxxxxxxxxxxxxxxx>> a écrit :
> Le 06/09/2024 à 00:13, Bruce Steers a écrit :
> > A method like CopyData or CopyNew or CopyContents or some other relevant 
> > word that copies an array contents as an actual copy without referencing 
> > would be awesome.
> > The Word Copy kinda misleads to think  you will get a true copy of the 
> > data instead of references. I've had to recursively copy arrays within 
> > arrays in some code to overcome the referencing.
> > Just a thought 😊
> > 
> 
> There is no "false" or "true" copy method, but "shallow" and "deep" copy.
> 
> You can't have a deep copy method of an array (or collection) contents 
> in Gambas, as there is no standard way for the interpreter to know how 
> to copy an object.
> 
> Regards,
> 
> -- 
> Benoît Minisini.
> 
> 
> 
> 
> -- 
> Fabien Bodard


Follow-Ups:
Re: Object copy function questionBenoît Minisini <benoit.minisini@xxxxxxxxxxxxxxxx>
References:
Object copy function questionLinus <olivier.cruilles@xxxxxxxx>
Re: Object copy function questionBenoît Minisini <benoit.minisini@xxxxxxxxxxxxxxxx>
Re: Object copy function questionBruce Steers <bsteers4@xxxxxxxxx>
Re: Object copy function questionBenoît Minisini <benoit.minisini@xxxxxxxxxxxxxxxx>
Re: Object copy function questionFabien Bodard <gambas.fr@xxxxxxxxx>