previous chapterthe pico pagenext chapter


Type functions

By now it is fairly clear that Pico values are partitioned into a number of distinct groups, called types. A value belongs to exactly one type and can never switch from one type to another. On the other hand, simply reading the text of a program is generally not sufficient to determine the type of the values that will be bound to the various variables and parameters used in the program. For instance:

if(a=0, x:=1, x:='one')

will assign either a number or a text value to the variable x, depending on the value for a retrieved from the current dictionary. As it is, the value of a could have been set using a totally unpredictable function, such as accept. The only way therefore to determine the types of values manipulated by a program consists of evaluating the program.Pico provides a number of native functions to identify the types of values as they are computed in a program:

The functions is_number, is_fraction, is_text, is_table and is_function generate either true or false depending on whether the value of their single argument is a number, a fraction, a text, a table or a function. The function is_void is used to determine whether the value of the argument is void; this value, accessible through the native variable void, is the only value of a type distinct from the five others, and is generally used to indicate the absence of value. Examples will be given in the next chapter.


previous chapterthe pico pagenext chapter