24.4.3 String Indexing

Poke supports accessing the characters in a string using the array indexing notation. The indexes are in the [0,n] range, where n is the length of the string minus one. Note the length doesn’t include the null character, i.e. it is not possible to access the terminating null. Examples:

(poke) "foo"[0]
0x66UB
(poke) "foo"[1]
0x6fUB

If the passed index is less than zero or it is too big, an E_out_of_bounds exception is raised:

(poke) "foo"[-1]
unhandled out of bounds exception
(poke) "foo"[3]
unhandled out of bounds exception

Poke also provides a way to refer to a character in a string by the offset the character occupies in the string. This is done by using as index an expression that evaluates to an offset value. This value is then implicitly promoted to have an unsigned 64-bit magnitude and unit bits whenever needed. If no character starts exactly at the provided offset then an E_out_of_bounds exception is raised.