next up previous contents index
Next: Top-level components Up: Compound statements Previous: Function definitions

Class definitions

    

A class definition defines a class object (see section gif):   

classdef:       "class" classname [inheritance] ":" suite
inheritance:    "(" [condition_list] ")"
classname:      identifier

A class definition is an executable statement. It first evaluates the inheritance list, if present. Each item in the inheritance list should evaluate to a class object. The class's suite is then executed in a new execution frame (see section gif), using a newly created local name space and the original global name space. (Usually, the suite contains only function definitions.) When the class's suite finishes execution, its execution frame is discarded but its local name space is saved. A class object is then created using the inheritance list for the base classes and the saved local name space for the attribute dictionary. The class name is bound to this class object in the original local name space.           



guido@cwi.nl