[DGD] Re: A slight confusion about light-weight objects
Erwin Harte
harte at is-here.com
Mon Mar 29 17:54:24 CEST 2004
On Mon, Mar 29, 2004 at 03:45:45PM +0000, Robert Forshaw wrote:
> In the docs it says:
>
> "If the master object is itself a light-weight object, it will be copied."
>
> Now, I don't see how it would be possible for the master object to be a
> light-weight object. As generating a light-weight object means calling
> new_object, and the parameter only accepts object pointers, the only way to
> obtain a master object would be with compile_object, surely? And if that's
> the case, then the initial object is never a light-weight object, its just
> a plain old heavy one. Which kind of defeats the purpose of having
> lightweight objects since the first instance (the master) still needs to be
> destructed!
May I suggest you clear your mind and re-read what you just quoted?
The kfun at hand has this prototype:
object new_object(object master)
And this is part of the description, with my comments added:
If the master object (that'd be 'master' up there) is itself a
light-weight object (so apparently new_object() can handle that just
fine), it will be copied.
So you can do something like this, it looks like:
object a, b, master;
master = compile_object("/data/foo");
a = new_object(master);
a->set_some_data(...);
b = new_object(a);
Cheers,
Erwin.
--
Erwin Harte <harte at is-here.com>
_________________________________________________________________
List config page: http://list.imaginary.com/mailman/listinfo/dgd
More information about the DGD
mailing list