Module: Types¶
Functions related to predefined types.
This is an automatic module, so these functions are available to all Chapel programs.
- proc isType(e) param¶
Returns true if the argument is a type.
- proc isParam(e) param¶
Returns true if the argument is a param.
- proc isPrimitiveType(type t) param¶
Returns true if the type t is a primitive type, as defined by the language specification.
- proc isNumericType(type t) param¶
Returns true if the type t is one the following types, of any width: int, uint, real, imag, complex.
- proc isIntegralType(type t) param¶
Returns true if the type t is one the following types, of any width: int, uint.
- proc isFloatType(type t) param¶
Returns true if the type t is one the following types, of any width: real, imag.
- proc isVoidType(type t) param¶
- proc isBoolType(type t) param¶
- proc isIntType(type t) param¶
- proc isUintType(type t) param¶
- proc isEnumType(type t) param¶
- proc isComplexType(type t) param¶
- proc isRealType(type t) param¶
- proc isImagType(type t) param¶
- proc isStringType(type t) param¶
Each of the above functions returns true if its argument is a corresponding type. The argument must be a type.
- proc isPrimitive(e) param¶
Returns true if the argument is a primitive type, as defined by the language specification, or a value of a primitive type.
- proc isNumeric(e) param¶
Returns true if the argument is one the following types, of any width: int, uint, real, imag, complex, or a value of such a type.
- proc isIntegral(e) param¶
Returns true if the argument is one the following types, of any width: int, uint, or a value of such a type.
- proc isFloat(e) param¶
Returns true if the argument is one the following types, of any width: real, imag, or a value of such a type.
- proc isBool(e) param¶
- proc isInt(e) param¶
- proc isUint(e) param¶
- proc isReal(e) param¶
- proc isImag(e) param¶
- proc isComplex(e) param¶
- proc isString(e) param¶
- proc isEnum(e) param¶
- proc isTuple(e) param¶
- proc isHomogeneousTuple(e: _tuple) param¶
- proc isClass(e) param¶
- proc isRecord(e) param¶
- proc isUnion(e) param¶
- proc isRange(e) param¶
- proc isDmap(e) param¶
- proc isDomain(e) param¶
- proc isArray(e) param¶
- proc isSync(e) param¶
- proc isSingle(e) param¶
- proc isAtomic(e) param¶
Each of the above functions returns true if its argument is a corresponding type or a value of such a type.
- proc isSubtype(type sub, type super) param¶
Returns true if the type sub is a subtype of the type super.
- proc isProperSubtype(type sub, type super) param¶
Returns true if the type sub is a subtype of the type super and is not super.
- proc numBits(type t) param¶
Returns the number of bits used to store the values of type t. This is available for all numeric types, fixed-width bool types, and enum types. It is not available for default-width bool.
- proc numBytes(type t) param¶
Returns the number of bytes used to store the values of type t. This is available for all numeric types, fixed-width bool types, and enum types. It is not available for default-width bool.
- proc min(type t) param¶
Returns the minimum value the type t can store. t can be one of the following types, of any width: bool, int, uint, real, imag, complex. When t is a bool type, it returns false. When t is real, imag, or complex type, it is a non-param function.
- proc max(type t) param¶
Returns the minimum value the type t can store. t can be one of the following types, of any width: bool, int, uint, real, imag, complex. When t is a bool type, it returns false. When t is a real, imag, or complex type, it is a non-param function.
- proc integral.safeCast(type T): T¶
Returns this, cast to the type T. Generates a run-time error if this cannot be represented by T, for example (-1).safeCast(uint) or 256.safeCast(uint(8)).
This method performs the minimum number of runtime checks. For example, when casting from uint(8) to uint(64), no checks at all will be done.