[saga-rg] deep copy / shallow copy

Andre Merzky andre at merzky.net
Sun Sep 11 07:10:28 CDT 2005


Quoting [Thilo Kielmann] (Sep 11 2005):
> 
> On Sun, Sep 11, 2005 at 01:47:02PM +0200, Andre Merzky wrote:
> > I think I disagree here.  For one thing, as far as I
> > understood there is no convention which holds for C++ in
> > general, or for C in general etc. 
> 
> Bad enough for C++...

Well, what is the convention in Java?  Is there any?


> > Second, that would lead to semantical differences in the
> > different languages.  I guess we don't want that.  E.g., the
> > following code would then possibly behave differently in
> > C++/Java:
> > 
> > +-----------------------------------------------------------------+
> >   saga::job_description jd_1 = my_job.get_job_description ();
> >   saga::job_description jd_2 = jd_1;
> > 
> >   jd_2.set_attribute ("SAGA_Host", "localhost");
> > +-----------------------------------------------------------------+
> > 
> > The state of jd_2 would differ in C++ and Java then, and I'd
> > think we would like to avoid that, don't we?  If we allow
> > that, you basically have to re-learn (small parts of) the
> > semantics for SAGA for each language...
> 
> Who cares? Again, this is a language detail, NOT SAGA.

That is what I disagree with :-)


> It is more important that SAGA doesn't prescibe deviations from "the
> usual things" in a language.
> 
> BTW: if you write a program in which this difference is important,
> your program is badly written. If you are the kind of programmer who
> makes use of these details, you know that you have to read the docs of
> your language binding (or even implementation) to find out...

The code snippet above is not badly written, but does depend
on the semantics of the copy operator.  Any assignement
operation (so any '=' with SAGA objects involved) will
expose the problem.  But you cannot argue that a programmer
using '=' is writing bad code ;-)

Cheers, Andre.


-- 
+-----------------------------------------------------------------+
| Andre Merzky                      | phon: +31 - 20 - 598 - 7759 |
| Vrije Universiteit Amsterdam (VU) | fax : +31 - 20 - 598 - 7653 |
| Dept. of Computer Science         | mail: merzky at cs.vu.nl       |
| De Boelelaan 1083a                | www:  http://www.merzky.net |
| 1081 HV Amsterdam, Netherlands    |                             |
+-----------------------------------------------------------------+





More information about the saga-rg mailing list