Name

aslist — Provides a type hint to the containing element that it is expecting a list value.

Syntax

aslist(expr, prototype)
              

The ASLIST function has the following arguments:

expr

The child expression that is expected to return a list data type value.

prototype

A literal list value that is used as a prototype of the hinted list data type.

Description

This function provides a type hint to the child expression that a list data type value is expected. If the expression does not provide a list valued result having the same data type as the prototype then an error will be raised.

This function is required in situations where the data type of the enclosed expression can not determined by the parser at compile time. This is typically due to an expression that is evaluated at runtime to determine a column from a data table, such as with the column, eval, tablelist, tablemap or tablerange functions. The type hint provided by the ASLIST function is then used for the semantic analysis required to complete the expression compilation.

No conversion of the data value returned by the child expression is attempted, and if the child data type does not match the hint an error will be generated. For type hinting with data conversion see the list function.

Examples

See the example Table range lookup with a non-literal value in the tablerange function for details about how type hints are used.

The prototype argument is a simple literal list of the same shape and value as the list type that is being hinted. For example, to hint that a list of strings is required, you could use a simple literal list such as

{'a'}

The data content within the type hint is ignored: only the list type signature is used. Many types of list can be used and here are a few of the prototype values:

{1}      // list of integer types
{true}   // list of boolean types
{0.0)    // list of number types
{{'a'}}  // list of list of strings