[saga-rg] deep copy / shallow copy

Craig Lee craig at rush.aero.org
Sun Sep 11 12:04:52 CDT 2005


At 05:15 AM 9/11/2005, Thilo Kielmann wrote:
>On Sun, Sep 11, 2005 at 02:10:28PM +0200, Andre Merzky wrote:
>
> > 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 ;-)
>
>Using '=' isn't bad. But creating an alias is
>(which, in fact, you do here ;-)

But that's the issue here:  depending on the copy/assignment semantics,
you are either (1) creating a copy, or (2) creating an alias.

This means that a SAGA programmer (to avoid "bad" programming)
would constantly have to be aware of the language binding context,
since each binding context could have different copy semantics.

But, one could argue that when programming in a given language,
the copy/assignment operator will be used for both SAGA and non-SAGA objects.
That is to say, the programmer should be/will be aware of the
copy/assignment semantics throughout the program.

I agree that differing copy/assignment semantics could cause problems
for a programmer, but I don't see how a SAGA binding could dictate 
copy/assignment
semantics that are different from a language's "native" semantics.
Besides being difficult or impossible to implement, this means that
different objects within a single program could have different copy/assignment
behavior, depending on whether they were SAGA or non-SAGA objects.
This, too, could cause problems.

I think this should be left as a language binding issue.  Nonetheless,
the SAGA API doc could have a prominent "Advice to Practitioners"
section that identifies and discusses these binding pitfalls.

my $0.02,

--Craig


>Thilo
>--
>Thilo Kielmann                                 http://www.cs.vu.nl/~kielmann/





More information about the saga-rg mailing list