
Hi all, during a discussion with Hartmut today, we stumbled over the question of copy behavious for the SAGA objects. Consider following code: ---------------------------------------------------------------------- 0 saga::job_description jd_1; 1 2 jd_1.set_attribute ("SAGA_Host", "host_1"); 3 4 cout << jd_1.get_attribute ("SAGA_Host")) << endl; 5 6 7 saga::job_description jd_2 = jd_1; 8 9 cout << jd_2.get_attribute ("SAGA_Host")) << endl; 10 11 jd_2.set_attribute ("SAGA_Host", "host_2"); 12 13 cout << jd_1.get_attribute ("SAGA_Hoset")) << endl; 13 cout << jd_2.get_attribute ("SAGA_Hoset")) << endl; ---------------------------------------------------------------------- What would that print? If the copy in line 4 is a deep copy, it would print: host_1 // jd_1 orig host_1 // jd_2 as copy from jd_1 host_1 // jd_1 orig still host_2 // jd_2 newly set if it is a shallow copy, it would be: host_1 // jd_1 orig <not defined> // jd_2 not defined yet host_1 // jd_1 orig still host_2 // jd_2 newly set if SAGA objects are only handled as references, it would be: host_1 // jd_1 orig host_1 // jd_2 as reference to jd_1 host_2 // jd_1 newly set (via jd_1 ref) host_2 // jd_2 just the same as jd_1 As the SAGA implementation should obviously show the same behaviour (either one for now), the spec needs to define that obviously. We think, that a default shallow copy is the most useful one. If for some objects a deep copy makes sense, a clone() method could be defined, which has the explicit semantics of a deep copy. If a reference is needed for some object, the native language can usually be used to obtain such one. So, if shallow copy as default, all three of the above cases seem easily implementable if needed. If there are no opinions against that, I'll add the respective note to the spec. Many thanks, Andre. -- +-----------------------------------------------------------------+ | Andre Merzky | phon: +31 - 20 - 598 - 7759 | | Vrije Universiteit Amsterdam (VU) | fax : +31 - 20 - 598 - 7653 | | Dept. of Computer Science | mail: merzky@cs.vu.nl | | De Boelelaan 1083a | www: http://www.merzky.net | | 1081 HV Amsterdam, Netherlands | | +-----------------------------------------------------------------+