Member Variables

A member variable is a variable that is associated with a specific object, and accessible for all its member methods.

Declaring Member Variables

When declaring a member variable, its data type must be specified. The declaration methods vary based on the data type of the variables:

Scalars

Scalars include basic data types such as INT, CHAR, FLOAT, DOUBLE, STRING, etc. The declaration method is: variableName :: dataType. For example: age :: INT, name :: STRING.

Regular Vectors

When declaring member variables as regular vectors, the method is similar to declaring scalars, but you need to add VECTOR after the data type to indicate that the member variable is a regular vector. The declaration method is: variableName :: dataType VECTOR. For example: age :: INT VECTOR, name :: STRING VECTOR.

Array Vectors

When declaring member variables as array vectors, the method is similar to declaring regular vectors, but you need to add [] after the data type to indicate that the member variable is an array vector. The declaration method is: variableName :: dataType[] VECTOR. For example: age :: INT[] VECTOR.

Columnar Tuple

A columnar tuple member variable is declared as: variableName :: ANY[DataType] VECTOR. For example: price :: ANY[INT].

Pairs

The declaration method for a PAIR member variable is: variableName :: dataType PAIR. The data type must be a scalar. For example: pr :: INT PAIR.

Matrics

The declaration method for a MATRIX member variable is: variableName :: dataType MATRIX. The data type must be a scalar. For example: m :: DOUBLE MATRIX.

Sets

The declaration method for a SET member variable is: variableName :: dataType SET. The data type must be a scalar. For example: st :: STRING SET.

Tables

The declaration method for a TABLE member variable is: variableName :: TABLE. For example: tb :: TABLE.

Dictionaries

The declaration method for a DICT member variable is: variableName :: DICT[keyType, valueType]. The key type must be a scalar. The value type supports any type annotation, including nested DICT, VECTOR, PAIR, MATRIX, SET, TABLE, and other supported types, with arbitrary nesting depth. For example:

  • d1 :: DICT[INT, DOUBLE]

  • d2 :: DICT[STRING, INT VECTOR]

  • d3 :: DICT[STRING, DICT[INT, DOUBLE]]

  • d4 :: DICT[INT, INT PAIR]

Class

The declaration method is variableName :: class name. For example: g :: X.

Other Types

For member variables that cannot be annotated using the types described above (such as stream processing engine objects), the ANY type can be used. The declaration method is: variableName :: ANY.

Retrieving Member Variables

Provides the attributeNames, attributeValues, and attributeTypes methods to retrieve all member variable names, their values, and types of a class instance.

class Person {
	
	name :: STRING
	age :: INT

	def Person(name_, age_) { 
		name = name_
		age = age_
	}
}

p = Person("Sam", 12)
attributeNames(p)
// output: ["name","age"]

attributeValues(p)
/* output:
name->Sam
age->12
*/

attributeTypes(p)
attr type
name STRING
age INT