Tuple operations

These operations are provided for working with tuple objects. Only the most commonly needed operations are supported. Generic operations such as AIterator and AIn can be used as well to perform additional operations.

Creating

AValue AMakeTuple(AThread *t, Assize_t len)
Create a std::Tuple object of the specified length. The object is initialized to contain nil values for all items. Use AInitTupleItem immediately to initilize the tuple.

Note: You must not use partially initialized tuple objects for any other purpose than for initializing them. In particular, you must not return them from functions, assign them to non-local variables or pass them as arguments to functions or operations.

Reading and updating

Assize_t ATupleLen(AValue v)
Return the length of a tuple. The argument must be a std::Tuple object. This function performs no error checking.
AValue ATupleItem(AValue v, Assize_t index)
Return the value of an item in a tuple. The first argument must be a std::Tuple object, and the index (0-based) must be non-negative and less than the length of the tuple. This function performs no error checking.
void AInitTupleItem(AThread *t, AValue v, Assize_t index, AValue item)
Initialize the value of an item in a tuple. The second argument must be a newly allocated std::Tuple object that is not visible to any Alore code, and the index (0-based) must be non-negative and less than then length of the tuple. This function performs no error checking of the argument values. Raise a direct exception if out of memory.

Checking

ABool AIsTuple(AValue v)
Return a boolean indicating whether the type of v is std::Tuple.