24. Introspection
24.1. Value inspection
- Method
arrayp
intarrayp(mixedarg)- Description
Returns
1ifargis an array,0(zero) otherwise.- See also
intp(),programp(),mappingp(),stringp(),objectp(),multisetp(),floatp(),functionp()
- Method
callablep
intcallablep(mixedarg)- Description
Returns
1ifargis a callable,0(zero) otherwise.- See also
mappingp(),programp(),arrayp(),stringp(),objectp(),multisetp(),floatp(),intp()
- Method
destructedp
intdestructedp(mixedarg)- Description
Returns
1ifargis a destructed object,0(zero) otherwise.- See also
zero_type,undefinedp,intp
- Method
floatp
intfloatp(mixedarg)- Description
Returns
1ifargis a float,0(zero) otherwise.- See also
intp(),programp(),arrayp(),multisetp(),objectp(),mappingp(),stringp(),functionp()
- Method
functionp
intfunctionp(mixedarg)- Description
Returns
1ifargis a function,0(zero) otherwise.- See also
mappingp(),programp(),arrayp(),stringp(),objectp(),multisetp(),floatp(),intp()
- Method
intp
intintp(mixedarg)- Description
Returns
1ifargis an int,0(zero) otherwise.- See also
mappingp(),programp(),arrayp(),stringp(),objectp(),multisetp(),floatp(),functionp()
- Method
mappingp
intmappingp(mixedarg)- Description
Returns
1ifargis a mapping,0(zero) otherwise.- See also
intp(),programp(),arrayp(),stringp(),objectp(),multisetp(),floatp(),functionp()
- Method
multisetp
intmultisetp(mixedarg)- Description
Returns
1ifargis a multiset,0(zero) otherwise.- See also
intp(),programp(),arrayp(),stringp(),objectp(),mappingp(),floatp(),functionp()
- Method
programp
intprogramp(mixedarg)- Description
Returns
1ifargis a program,0(zero) otherwise.- See also
mappingp(),intp(),arrayp(),stringp(),objectp(),multisetp(),floatp(),functionp()
- Method
undefinedp
intundefinedp(mixedarg)- Description
Returns
1ifargis undefined,0(zero) otherwise.- See also
zero_type,destructedp,intp
24.2. Content inspection
- Method
indices
arrayindices(string|array|mapping|multiset|objectx)- Description
Return an array of all valid indices for the value
x.- Parameter
x stringFor strings and arrays this is simply an array of ascending numbers.
mappingFor mappings and multisets, the array might contain any value.
objectFor objects which define
lfun::_indices()that return value is used.For other objects an array with the names of all non-protected symbols is returned.
- See also
values(),types(),lfun::_indices()
- Method
values
arrayvalues(string|array|mapping|multiset|objectx)- Description
Return an array of all possible values from indexing the value
x.- Parameter
x stringFor strings an array of int with the ISO10646 codes of the characters in the string is returned.
multisetFor a multiset an array filled with ones (
1) is returned.arrayFor arrays a single-level copy of
xis returned.mappingFor mappings the array may contain any value.
objectFor 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(),types(),lfun::_values()
- Method
types
array(type) types(string|array|mapping|multiset|object|programx)- Description
Return an array with the types of all valid indices for the value
x.- Parameter
x stringFor strings this is simply an array with int
arrayFor arrays, mappings and multisets this is simply an array with mixed.
objectFor objects which define
lfun::_types()that return value is used.For other objects an array with type types for all non-protected symbols is returned.
- Note
This function was added in Pike 7.9.
- See also
indices(),values(),lfun::_types()
- Method
annotations
array(multiset(Pike.Annotation)) annotations(object|program|function(:void)x,bool|voidrecurse)- Description
Return an array with the annotations for all symbols in
x.- Parameter
x objectFor objects which define
lfun::_annotations()that return value is used.For other objects an array with annotations for all non-protected symbols is returned.
programReturns an array with annotations for all non-protected constant symbols.
- Parameter
recurse Include annotations recursively added via inherits.
- Returns
The order of the resulting array is the same as that of
indices()for the samex.- Note
This function was added in Pike 8.1.
- See also
indices(),values(),types(),lfun::_annotations(),::_annotations(),Program.annotations
- Method
get_weak_flag
intget_weak_flag(array|mapping|multisetm)- Description
Returns the weak flag settings for
m. It's a combination ofPike.WEAK_INDICESandPike.WEAK_VALUES.
24.3. Integer inspection
- Method
zero_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 iszero_type().- Returns
When doing a
find_call_out()or mapping lookup,zero_type()on this value will return1if 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,2will be returned.In all other cases
zero_type()will return0(zero).- See also
find_call_out()
24.4. Function inspection
- Method
function_name
stringfunction_name(function(:void)|programf)- Description
Return the name of the function or program
f.If
fis a global function defined in the runtime0(zero) will be returned.- See also
function_object()
- Method
function_object
objectfunction_object(function(:void)f)- Description
Return the object the function
fis in.If
fis a global function defined in the runtime0(zero) will be returned.Zero will also be returned if
fis a constant in the parent class. In that casefunction_program()can be used to get the parent program.- See also
function_name(),function_program()
- Method
function_program
programfunction_program(function(:void)|programf)- Description
Return the program the function
fis in.If
fis a global function defined in the runtime0(zero) will be returned.- See also
function_name(),function_object()
24.5. Object inspection
- Method
object_program
program|function(:void) object_program(mixedo)- Description
Return the program from which
owas instantiated. If the object was instantiated from a class using parent references the generating function will be returned.If
ois not an object or has been destructed0(zero) will be returned.
24.6. Program inspection
- Method
get_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_clonesThe first element is the number of times the program
proghas been instantiated.mapping(string:array(int))fun_prof_infoThe second element is mapping from function name to an array with three elements.
Array intnum_callsThe first element is the number of times the function has been called.
inttotal_timeThe second element is the total time (in milliseconds) spent executing this function, and any functions called from it.
intself_timeThe 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.
- Method
typeof_identifier
type|zerotypeof_identifier(programp,stringidentifier)- Description
Allows access to the static type of an identifier ("member") in a program.
- Returns
The static type of
p->identifier, orUNDEFINEDif it can not be determined, be it becauseidentifierdoes not exist inpor for other reasons.