[Xotcl] Object destruction on exit

Kristoffer Lawson setok at fishpool.com
Sat Feb 4 11:39:58 CET 2006


On 3 Feb 2006, at 17:11, Gustaf Neumann wrote:

> Kristoffer Lawson schrieb:
>
>>
>> Well this generally happens automatically anyway. If they are   
>> resources for which this does not happen, can we be sure that this
>> is what the programmer wants?
>
> consitency is important.
> in oo-systems, the programmer has a "contract" with the system,  
> that for every object
> the life-cycle starts with the constructor and ends for the  
> destructors.
> This is simlar to finalize() in java.
> normally, you  do not want to distinguish btwn. "manual" and  
> "automatic" destroys (which happen
> btw. in various situations).

I would say this depends very much on your point of view. In systems  
with prevalent persistence then the existence of an object continues  
until it is explicitly destroyed. Ie. automatic destruction does not  
occur. You can few objects in two different ways, as in-memory  
entities they exist only as long as the application exists. But you  
can also take the view that the in-memory entities are just  
representations of the actual object, which resides also on disc.

> You cound do e.g.
>
> ::xotcl::Object setExitHandler {set ::xotcl::onEXIT 1}
>
> and check this variable from the destroy method whether or not  the  
> db-instance
> should be deleted.

Yes, this could be one possible way round that.

            /  http://www.fishpool.com/~setok/



More information about the Xotcl mailing list