Inheritance

SBM object types have a hierarchical inheritance structure compatible with but not generally seen in ChaiScript. If an object type S inherits from another object type B, then S is a "subtype" of B, and B is a "base type" for S. This means all methods and properties of B are available to S. It also means objects of type S are considered to be of type B as well, though objects of type B are not necessarily of type S.

The following diagram shows the SBM inheritance hierarchy. Arrows point from base types to subtypes.

Figure 1. object inheritance hierarchy

For example, AppRecord is a base type whose many subtypes include Field and Project. AppRecord has a method called GetName(), which returns a string. GetName() is not a method of Field or Project, but those types inherit it from AppRecord. Thus, GetName() can be called on objects of type Field and Project. In addition, objects of type Field and Project can be used anywhere an object of type AppRecord is expected. And, because AppRecord is a base type, any AppRecord might also be a Field or Project or some other subtype.

"Inheritance" information is included for each object type, using similar arrow notation. For example, "AppRecord --> User" means the object type AppRecord is the base type for User.

Related Topics

Creating SBM Application Objects

Object Types