Compute the length of a string or array

Syntax

LENGTH …string-expr…

LENGTH …array…

Typing

STRING -> U32

t[] -> U32

Description

Returns the number of bytes in a string.

For now, strings are just variable length sequences of bytes. However, the plan is to make them UTF8 though.

Can also return the length of an array.

Examples

expression evaluates to
LENGTH "foo" 3
LENGTH "" 0
LENGTH CAST([42] AS U8[]) 1