Data types: Certain Chora class

Represents an object of a certain Chora class.

Type syntax

unit‑name::class‑name

Literal syntax

null

Discussion

Operands of this data type are intended to store references to objects of a certain Chora class and all classes derived from it. Chora compiler ensures, that the operands are never initialized with objects not descended from the specified class.

A certain class data type must always consist of two identifiers: the name of the unit containing the class definition and the name of the class itself, both separated by :: (double colon). The type is designated to be used in declarations of data members able to refer to objects of the corresponding class. The literal, in turn, can assume the value null only to identify 'no object'. For example:

var Core::View theView = null; // 'theView' doesn't refer to any Chora object

theView = SomeTextView;        // now 'theView' refers to a text view

[...]

theView = SomeImageView;       // now 'theView' refers to an image view

if ( theView != null )
  trace "theView refers to an object";

Instantiating objects

The certain class data types can be used in conjunction with the new operator to create new instances of the respective class.

Evaluating object's class

With the classof operator, you can determine the class of the object actually represented by the operand.

Performing safe typecasts

You can perform a runtime type casting operation on the object represented by the operand in order to determine, whether it descends from a particular class or not.

Comparison operations

You can compare two object operands in order to test whether these refer to the same instance or not. The following table provides an overview of the possible operations:

Operator

Short description

==

Equality test for two object operands.

!=

Inequality test for two object operands.