5.2. Construction and Destruction

The constructor and destructor methods help with general class housekeeping.

method Application.constructor ()
{
    ._Instances = cons (self, ._Instances);
}

The constructor adds each instance of the class to the list of all the class instances currently defined in Gamma. The Gamma cons function is used to build the list.

method Application.destructor ()
{
    local   id;
    
    ._Instances = remove (self, ._Instances);
    .RemoveAllEventHandlers ();
    .RemoveAllMenus ();
    
    if (!._AllMenuActions)
    {
        .RemoveSystemMenu();
    }
}

When an instance of the class gets destroyed, this destructor method will be run first. It removes this instance of the class from the _Instances list using the Gamma remove function. Then it removes all event handlers and menus, using the RemoveAllEventHandlers, RemoveAllMenus, and RemoveSystemMenu, as applicable.