Glish provides the following functions for identifying the type of a value:
is_byte(x)
is_short(x)
is_integer(x)
is_float(x)
is_double(x)
is_complex(x)
is_dcomplex(x)
is_string(x)
is_record(x)
is_function(x)
is_agent(x)
type_name(5)returns "integer" and
type_name(func (x) x+1)returns "function". The names of the various types are:
"boolean"
"byte"
"short"
"integer"
"float"
"double"
"complex"
"dcomplex"
"string"
"record"
"function"
"agent"
"fail"
The name of a reference type is the concatenation of the string "ref" followed by the name of the referred-to type. For example,
type_name(ref "hi")yields 'ref string' as a scalar value.
If the value is a vector with more than one element then the function reports its size as well as its type:
full_type_name(1:10)yields 'integer [10]'.
If the value is a record then the function identifies each field's name and type (recursively, if one of the fields is itself a record):
full_type_name([a=1, b="how are you?", c=2:5])yields
'record [a=integer, b=string [3], c=integer [4]]'
If the value is a reference then the function returns only its referred-to type:
full_type_name(ref 5)returns 'integer'.
field_names([a=1, b="how are you?", c=2:5])yields "a b c".
If x is not a record than an error message is printed and F returned.