Construction/initialization and destruction/cleaning up.

PRIMA makes a distinction between construction and initialization. The only constructor in standard PRIMA class hierarchy is Prima::Object::create. It calls several auxiliary XS functions which set the links between Perl and C parts of an object properly. At the end, the initialization method init is called. Normally init is overridden in every PRIMA class. For a normal PRIMA operation it is absolutely necessary for an object's init to call its SUPER::init, preferably near init's beginning. init takes a list of property name/property value pairs as parameters, and has to return this profile to a caller after possible modifications. The properties in a profile are already merged with the default profile and validated by profile_check_in at the time init is called.

The distinction between destruction and cleaning up is more important, because the destruction can be initiated from three places: in Perl, in C, and when a platform specific window object corresponding to the PRIMA widget ceases to exist. The clean-up method is called done. PRIMA guarantees that it will be invoked exactly once, whatever ``destruction path'' an object will follow. Under normal conditions, a PRIMA object is not destroyed when Perl variable holding a reference to it goes out of scope or gets assigned to. This happens because an owner of the objects holds references to all its children. On the other hand, if an object is ``half-dead'', i.e. its method done was already called, it is still possible that the object is referenced by one or more Perl variables. Although the object cannot do much being in this state, PRIMA respects Perl rules and DESTROY will not be called prematurely.