type_of
var type_of(var self);
Returns the Type of an object self.
instance
var instance(var self, var cls);
var type_instance(var type, var cls);
Returns the instance of class cls implemented by object self or type type. If class is not implemented then returns NULL.
implements
bool implements(var self, var cls);
bool type_implements(var type, var cls);
Returns if the object self or type type implements the class cls.
method
#define method(X, C, M, ...)
#define type_method(T, C, M, ...)
Returns the result of the call to method M of class C for object Xor type T. If class is not implemented then an error is thrown.
implements_method
#define implements_method(X, C, M)
#define type_implements_method(T, C, M)
Returns if the type T or object X implements the method M of class C.
Usage
var t = type_of($I(5));
show(t); /* Int */
show($I(type_implements(t, New)));  /* 1 */
show($I(type_implements(t, Cmp)));  /* 1 */
show($I(type_implements(t, Hash))); /* 1 */
show($I(type_method(t, Cmp, cmp, $I(5), $I(6))));
Metadata Object
The Type type is one of the most important types in Cello. It is the object which specifies the meta-data associated with a particular object. Most importantly this says what classes an object implements and what their instances are.
One can get the type of an object using the type_of function.
To see if an object implements a class implements can be used. To call a member of a class with an object method can be used.
To see if a type implements a class type_implements can be used. To call a member of a class, implemented type_method can be used.
$ alloc dealloc assign c_str cmp eq neq gt lt ge le copy name brief description definition hash hash_data help new del construct destruct show look print scan