Skip to content

tuple_typeTupleTypeTupleTypetuple_typetuple_type🔗

Short description🔗

tuple_typeTupleTypeTupleTypetuple_typetuple_type — Return the type of a tuple.

Signature🔗

tuple_type( tuple T, out number Type )void TupleType( const HTuple& T, HTuple* Type )static void HOperatorSet.TupleType( HTuple t, out HTuple type )def tuple_type( t: HTupleType ) -> int

Herror tuple_type( double T, Hlong* Type )

Herror T_tuple_type( const Htuple T, Htuple* Type )

HTuple HTuple::TupleType( ) const

HTuple HTuple.TupleType( )

Description🔗

tuple_typeTupleType returns the type of the input tuple Ttt. The type is returned as an integer value in the output parameter Typetypetype. In HDevelop corresponding constants are defined:

  • H_TYPE_INT (1).

  • H_TYPE_REAL (2).

  • H_TYPE_STRING (4).

  • H_TYPE_MIXED (8).

  • H_TYPE_HANDLE (16).

  • H_TYPE_ANY (31).

H_TYPE_MIXED is returned in the following two cases:

  • some elements of the tuple have different data types, e.g., real and integer.

  • the tuple Ttt has undergone operations which modified the data type of single elements. Such tuples will generally not be optimized automatically (because of runtime reasons) even if the data types of all elements become equal in subsequent operations. See tuple_is_mixedTupleIsMixed and the following example on how to optimize such tuples.

Exception: Empty input tuple🔗

If the input tuple is empty, the operator returns 31 (H_TYPE_ANY).

HDevelop In-line Operation🔗

HDevelop provides an in-line operation for tuple_typeTupleType, which can be used in an expression in the following syntax:

Type := type(T)

Attention🔗

tuple_typeTupleType returns the internal data type of the tuple. In contrast to tuple_is_numberTupleIsNumber it does not return whether a tuple could be represented as a tuple of a certain type.

Execution information🔗

Execution information
  • Multithreading type: reentrant (runs in parallel with non-exclusive operators).

  • Multithreading scope: global (may be called from any thread).

  • Processed without parallelization.

Parameters🔗

Ttt (input_control) tuple(-array) → (real / integer / string / handle)HTuple (double / Hlong / HString / HHandle)HTuple (double / int / long / string / HHandle)HTupleTypeHtuple (double / Hlong / char* / handle)

Input tuple.

Typetypetype (output_control) number → (integer)HTuple (Hlong)HTuple (int / long)intHtuple (Hlong)

Type of the input tuple as an integer number.

Example🔗

(HDevelop)

tuple_type ([3.1416,'pi',3], TypeA)
* TypeA = H_TYPE_MIXED
tuple_type (['a','b','111'], TypeB)
* TypeB = H_TYPE_STRING
tuple_type ([], TypeC)
* TypeC = H_TYPE_ANY
tuple_type (HNULL, TypeD)
* TypeD = H_TYPE_HANDLE

TupleInt := [1,2,3,4]
TupleReal := [42.0]
TupleConcat := [TupleInt, TupleReal]
tuple_type (TupleConcat, TypeConcat)
* TypeConcat = H_TYPE_MIXED
* Now set 42.0 to 42
TupleConcat[4] := 42
tuple_type (TupleConcat, TypeConcat2)
* TypeConcat2 = H_TYPE_MIXED
* TupleConcat now consists of integers only, but the
* internal representation hasn't been updated. Optimize
* it by converting the tuple explicitly to an integer
* tuple.
tuple_int (TupleConcat, TupleConcatInt)
tuple_type (TupleConcatInt, TypeConcatInt)
* TypeConcatInt = H_TYPE_INT

Result🔗

If the parameters are valid, the operator tuple_typeTupleType returns the value 2 (H_MSG_TRUE).

Combinations with other operators🔗

Combinations

Alternatives

tuple_is_intTupleIsInt, tuple_is_numberTupleIsNumber, tuple_is_realTupleIsReal, tuple_is_stringTupleIsString, tuple_sem_typeTupleSemType

See also

get_obj_classGetObjClass

Module🔗

Foundation