Data Types and Predicates

— testing for data types.

Unlike many languages, just about every expression in Gamma is a data type. This gives the flexibility to manipulate functions, arrays, lists, classes, instances and so on as if they were data.

The following data types are defined in Gamma. Beside each data type is the name of a function which can be used to test an expression for that type. These functions are called predicates, and will return t if the test is true (the expression is that data type), or nil if it is false.

Table3.Data Types and Related Predicates

alistalist_pAn association list. See assoc.
arrayarray_pSee array and Lists and Arrays.
bufferbuffer_pSee buffer.
classclass_pSee class.
conscons_pSee cons and list.
constantconstant_pConstants can be assigned or defined. See defvar and ::=.
destroyed instancedestroyed_pSee new(instance).
filefile_p See open and open_string.
fixed-point realfixed_point_pSee Numeric Types.
functionfunction_pSee function.
instanceinstance_pSee new(instance).
integerint_p, long_pSee Literals.
listlist_pSee list and Lists and Arrays.
macromacro_pSee macro.
methodmethod_p (obsolete, always returns nil)See method.
nilnil_pSee nil.
numbernumber_pInteger and floating point values are both considered numbers. See Literals.
realreal_pSee Literals.
registeredregistered_pSee register_point.
stringstring_pSee Literals and string.
sym-alistsym_alist_pA symbol-indexed association list. See assoc.
symbolsymbol_pSee Literals.
ttrue_pSee t.
task descriptornoneSee locate_task.
undefinedundefined_pSee undefined_p.
undefined symbolundefined_symbol_pSee undefined_symbol_p.


Predicates are used to test a Gamma object for a given type, as listed. If a Gamma object is of that type, the predicate will return the value t.


alist_p (s_exp)
array_p (s_exp)
autotrace_p (s_exp)
breakpoint_p (s_exp)
buffer_p (s_exp)
builtin_p (s_exp)
class_p (s_exp)
cons_p (s_exp)
constant_p (s_exp)
destroyed_p (s_exp)
file_p (s_exp)
fixed_point_p (s_exp)
function_p (s_exp)
instance_p (s_exp)
int_p (s_exp)
list_p (s_exp)
long_p (s_exp)
macro_p (s_exp)
method_p (s_exp)
nil_p (s_exp)
number_p (s_exp)
real_p (s_exp)
registered_p (s_exp)
string_p (s_exp)
sym_alist_p (s_exp)
symbol_p (s_exp)
true_p (s_exp)
none_p (s_exp)
undefined_p (s_exp)
undefined_symbol_p (s_exp)


any expression


t or nil.


Here is an example for the predicate function_p. All the other predicates work in a similar way.

Gamma> function_p(div);
Gamma> function_p(strcmp);
Gamma> function_p(5);