Data types: handle

Represents a safe reference to a target system resource.

Type syntax


Literal syntax



Operands of this data type are intended to store references to target specific system resources. From Chora's point of view, handle operands are abstract data entity with not exactly specified content. Accordingly, you can store and compare references, accessing or modifying the respective system resources is, in turn, not possible. In analogy to the programming language C, you can consider handle operands as void* pointers. The data type handle is useful when implementing native code to interact and exchange data with the target system.

The handle literal can be null only to explicitly identify no reference to a system resource. The literal can be used within expressions wherever a handle operand is expected. The type name handle, in turn, is designated to be used in declarations of data members. For example:

var handle theFile = null; // 'theFile' doesn't refer to any system resource

// In 'C' code, initialize 'theFile' with a reference to e.g. a file
native ( theFile )
  theFile = (XHandle)fopen( "filename", "rt" );

if ( theFile != null )
  trace "theFile refers to a system resource.";

// Again in 'C' close the file
native ( theFile )
  fclose((FILE*)theFile );
  theFile = 0;

Comparison operations

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


Short description


Equality test for two handle operands.


Inequality test for two handle operands.