Vincent, Functions, options can always be added in a class. The problem is that this makes the system more and more complex. In your example, you suggest to add an option in the list to say " I am the owner of the objects in my list". Don't you think it is simpler to do list->Delete() when you destroy the list than call a function after the list constructor to specify the ownership? It looks to me more logical to concentrate things in the destructor where logically you have to think about the problem. With your proposal, somebody looking at the code will have to look at two places in case he suspects memory leaks. Your point about adding an object at an already allocated slot is different. A warning must be issued. Rene Brun Vincent Colin de Verdiere wrote: > > Hi Rooters, > > Currently, from what I have seen, if I have a TObjArray* A, when I delete > it, its members are not deleted unless I run A->Delete() before. The same > applies to lists. I wonder if it would be possible to add some "adoption" > mecanism which would give the responsibility of destroying objects to the > array when it is deleted. > > Then for deletion, people would only need to delete the array.. It saves > one line of code ! ;-) and it costs several lines in the array class plus > a boolean value to activate this behaviour. ;-( > > But, the main point is that it would save, to my view, a lot of memory > loss mistakes: > when you set a new value to a bin of the array. A.At(x, i) would delete > previous object if present. It has a cost and should not be set by default > but is very usefull... I have used to it in another "somewhat" similar > system and it was very pratical ! > > Comments ? > > A second small point on histograms ! > I feel that function GetMaximum() and GetMaximumBin() are quite redundant > functions. A single one could do both ! > > -- Vincent > > Vincent Colin de Verdiere (vincent.colin.de.verdiere@cern.ch) > at work: CERN, division EP, Office 13-1-038, CH - 1211 Geneva 23 > tel: (+41) 22 76 72839, fax: (+41) 22 767 9075 > http::/www-prima.imag.fr/Prima/colin/homeGB.html
This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:19 MET