23. Introspection

23.1. Value inspection


Methodarrayp

intarrayp(mixedarg)

Description

Returns 1 if arg is an array, 0 (zero) otherwise.

See also

intp(), programp(), mappingp(), stringp(), objectp(), multisetp(), floatp(), functionp()


Methodcallablep

intcallablep(mixedarg)

Description

Returns 1 if arg is a callable, 0 (zero) otherwise.

See also

mappingp(), programp(), arrayp(), stringp(), objectp(), multisetp(), floatp(), intp()


Methoddestructedp

intdestructedp(mixedarg)

Description

Returns 1 if arg is a destructed object, 0 (zero) otherwise.

See also

zero_type, undefinedp, intp


Methodfloatp

intfloatp(mixedarg)

Description

Returns 1 if arg is a float, 0 (zero) otherwise.

See also

intp(), programp(), arrayp(), multisetp(), objectp(), mappingp(), stringp(), functionp()


Methodfunctionp

intfunctionp(mixedarg)

Description

Returns 1 if arg is a function, 0 (zero) otherwise.

See also

mappingp(), programp(), arrayp(), stringp(), objectp(), multisetp(), floatp(), intp()


Methodintp

intintp(mixedarg)

Description

Returns 1 if arg is an int, 0 (zero) otherwise.

See also

mappingp(), programp(), arrayp(), stringp(), objectp(), multisetp(), floatp(), functionp()


Methodmappingp

intmappingp(mixedarg)

Description

Returns 1 if arg is a mapping, 0 (zero) otherwise.

See also

intp(), programp(), arrayp(), stringp(), objectp(), multisetp(), floatp(), functionp()


Methodmultisetp

intmultisetp(mixedarg)

Description

Returns 1 if arg is a multiset, 0 (zero) otherwise.

See also

intp(), programp(), arrayp(), stringp(), objectp(), mappingp(), floatp(), functionp()


Methodprogramp

intprogramp(mixedarg)

Description

Returns 1 if arg is a program, 0 (zero) otherwise.

See also

mappingp(), intp(), arrayp(), stringp(), objectp(), multisetp(), floatp(), functionp()


Methodundefinedp

intundefinedp(mixedarg)

Description

Returns 1 if arg is undefined, 0 (zero) otherwise.

See also

zero_type, destructedp, intp


Method_typeof

type_typeof(mixedx)

Description

Return the runtime type of x.

See also

typeof()

23.2. Content inspection


Methodindices

arrayindices(string|array|mapping|multiset|objectx)

Description

Return an array of all valid indices for the value x.

For strings and arrays this is simply an array of ascending numbers.

For mappings and multisets, the array might contain any value.

For objects which define lfun::_indices() that return value is used.

For other objects an array with all non-protected symbols is returned.

See also

values()


Methodvalues

arrayvalues(string|array|mapping|multiset|objectx)

Description

Return an array of all possible values from indexing the value x.

For strings an array of int with the ISO10646 codes of the characters in the string is returned.

For a multiset an array filled with ones (1) is returned.

For arrays a single-level copy of x is returned.

For mappings the array may contain any value.

For objects which define lfun::_values() that return value is used.

For other objects an array with the values of all non-protected symbols is returned.

See also

indices()


Methodget_weak_flag

intget_weak_flag(array|mapping|multisetm)

Description

Returns the weak flag settings for m. It's a combination of Pike.WEAK_INDICES and Pike.WEAK_VALUES.

23.3. Integer inspection


Methodzero_type

intzero_type(mixeda)

Description

Return the type of zero.

There are many types of zeros out there, or at least there are two. One is returned by normal functions, and one returned by mapping lookups and find_call_out() when what you looked for wasn't there. The only way to separate these two kinds of zeros is zero_type().

Returns

When doing a find_call_out() or mapping lookup, zero_type() on this value will return 1 if there was no such thing present in the mapping, or if no such call_out could be found.

If the argument to zero_type() is a destructed object or a function in a destructed object, 2 will be returned.

In all other cases zero_type() will return 0 (zero).

See also

find_call_out()

23.4. Function inspection


Methodfunction_name

stringfunction_name(function(:void) f)

Description

Return the name of the function f.

If f is a global function defined in the runtime 0 (zero) will be returned.

See also

function_object()


Methodfunction_object

objectfunction_object(function(:void) f)

Description

Return the object the function f is in.

If f is a global function defined in the runtime 0 (zero) will be returned.

Zero will also be returned if f is a constant in the parent class. In that case function_program() can be used to get the parent program.

See also

function_name(), function_program()


Methodfunction_program

programfunction_program(function(:void)|programf)

Description

Return the program the function f is in.

If f is a global function defined in the runtime 0 (zero) will be returned.

See also

function_name(), function_object()

23.5. Object inspection


Methodobject_program

program|function(:void) object_program(mixedo)

Description

Return the program from which o was instantiated. If the object was instantiated from a class using parent references the generating function will be returned.

If o is not an object or has been destructed 0 (zero) will be returned.

23.6. Program inspection


Methodget_profiling_info

array(int|mapping(string:array(int))) get_profiling_info(programprog)

Description

Get profiling information.

Returns

Returns an array with two elements.

Array
intnum_clones

The first element is the number of times the program prog has been instantiated.

mapping(string:array(int)) fun_prof_info

The second element is mapping from function name to an array with three elements.

Array
intnum_calls

The first element is the number of times the function has been called.

inttotal_time

The second element is the total time (in milliseconds) spent executing this function, and any functions called from it.

intself_time

The third element is the time (in milliseconds) actually spent in this function so far.

Note

This function is only available if the runtime was compiled with the option --with-profiling.

23.7. Type inspection