Data types and Coercion

The following table summarizes the intrinsic data types in 4RPL and how they are coerced 1). To read the table, look at a datatype in the left column. To see how a variable of that data type is coerced, look across it's row to the column it is being coerced to. For instance, if you treat a string as an int, the “Parse to int” operation will be performed on the int. If you treat a list as a string (say, you trace a list), the list will be turned into comma separate strings (suitable for human eyeball consumption).

int float string list table vector
int int float ToString Empty List Empty Table V4(int,0,0,0)
float int float ToString Empty List Empty Table V4(float,0,0,0)
string Parse To int Parse To Float string Empty List Empty Table V4(Parse to float,0,0,0)
list List Length List Length Comma Separated 1) list Table from list2) V4(List Length,0,0,0)
table Table Length Table Length Comma Separated 3) Table Keys as List table V4(Table length,0,0,0)
vector Vector Length Vector Length Comma Separated List of x,y,z,w Table of x,y,z,w4) vector
null 0 0.0 Empty String Empty List Empty Table V4(0,0,0,0)

1), 3) See note in AsString command for forcible truncation of lists and tables converted to a string.
2) A 'Table from list' is constructed by taking each item in a list and adding it to a table where the item's string representation becomes the key and the item becomes the value.
4) A 'Table of x,y,z,w' is constructed by taking each value in a vector and adding it to a table where the keys are “0”,“1”,“2”,“3”.

Comparisons

Values can be compared using the eq,neq,lt,lte,gt,gte operators. All of these commands take two values and compare them. The following table summarizes the type of comparison that is done based on the types of the two values being compared. A 'float comparison', means that both types are coerced as floats, etc.

1)
Forcible type conversion