8. Special object functions

8.1. LFUN

Namespace lfun::

Description

Callback functions used to overload various builtin functions.

The functions can be grouped into a few sets:

  • Object initialization and destruction.

    __INIT(), create(), _destruct()

  • Unary operator overloading.

    `~(), `!(), _values(), cast(), _sizeof(), _indices(), __hash()

  • Binary asymmetric operator overloading.

    `+(), ``+(), `-(), ``-(), `&(), ``&(), `|(), ``|(), `^(), ``^(), `<<(), ``<<(), `>>(), ``>>(), `*(), ``*(), `/(), ``/(), `%(), ``%()

  • Binary symmetric operator overloading.

    The optimizer will make assumptions about the relations between these functions.

    `==(), _equal(), `<(), `>()

  • Other binary operator overloading.

    `[](), `[]=(), `->(), `->=(), `+=(), `()()

  • Overloading of other builtin functions.

    _is_type(), _sprintf(), _m_delete(), _get_iterator(), _search()

Note

Although these functions are called from outside the object they exist in, they will still be used even if they are declared protected. It is in fact recommended to declare them protected, since that will hinder them being used for other purposes.

See also

::


Variablesymbol

mixed lfun::symbol


Method__INIT

void__INIT()

Description

Inherit and variable initialization.

This function is generated automatically by the compiler. It's called just before lfun::create() when an object is instantiated.

It first calls any __INIT functions in inherited classes (regardless of modifiers on the inherits). It then executes all the variable initialization expressions in this class, in the order they occur.

Note

This function can not be overloaded or blocked from executing.

See also

lfun::create()


Method__create__

void__create__(__unknown__ ... args)

Description

Low-level object creation callback.

This function is generated automatically by the compiler for inline classes that declare parameters. A call to it and its arguments are automatically added to user-supplied lfun::create()

Note

This function is typically created implicitly by the compiler using the syntax:

class Foo(int foo){int bar;}

In the above case an implicit lfun::__create__() is created, and it's equivalent to:

class Foo {int foo;int bar;localprotectedvoid __create__(int foo){this::foo = foo;}}
Note

Note also that in case lfun::create() does not exist, it will be created as an alias for this function.

Note

This function did not exist in Pike 8.0 and earlier (where it was instead automatically inlined in lfun::create().

See also

lfun::create(), lfun::__INIT()


Method__hash

int__hash()

Description

Hashing callback.

The main caller of this function is predef::hash_value() or the low-level equivalent, which get called by various mapping operations when the object is used as index in a mapping.

Returns

It should return an integer that corresponds to the object in such a way that all values which lfun::`== considers equal to the object get the same hash value.

Note

The function predef::hash does not return hash values that are compatible with this one.

Note

It's assumed that this function is side-effect free.

See also

lfun::`==, predef::hash_value()


Method_annotations

array_annotations(object|voidcontext, int|voidaccess, bool|voidrecursive)

Description

Called by annotations()

Parameter context

Inherit in the current object to return the annotations for. If UNDEFINED or left out, this_program::this should be used (ie start at the current context and ignore any overloaded symbols).

Parameter access

Access permission override. One of the following:

0

See only public symbols.

UNDEFINED
1

See protected symbols as well.

Parameter recursive

Include nested annotations from the inherits.

See also

annotations()


Method_atomic_get_set

mixed_atomic_get_set(mixedindex, mixedvalue)

Description

Get and set the value for an index atomically.

Parameter index

Index for which to get and set the value.

Parameter value

Value to set.

Returns

Returns the previous value at index index.

See also

lfun::`->=(), lfun::`[]=(), atomic_get_set(), lfun::_m_delete(), lfun::`[](), lfun::`->()


Method_deserialize

void_deserialize(objecto, function(function(mixed:void), string, type:mixed) deserializer)

Description

Dispatch function for Serialization.deserialize().

Parameter o

Object to serialize. Always a context of the current object.

Parameter deserializer

Function to be called once for every variable to serialize.

The deserializer function expects to be called with three arguments:

setter - Function that sets the symbol value.

symbol - The symbol name.

symbol_type - The type of the symbol.

Note

A default implementation of lfun::_serialize() and lfun::_deserialize() is available in Serializer.Serializable.

See also

lfun::_serialize(), Serializer.deserialize(), Serializer.Serializable()->_deserialize()


Method_destruct

void_destruct(void|intreason)

Description

Object destruction callback.

This function is called right before the object is destructed. That can happen either through a call to predef::destruct(), when there are no more references to the object, or when the garbage collector discovers that it's part of a cyclic data structure that has become garbage.

Parameter reason

A flag that tells why the object is destructed:

Object.DESTRUCT_EXPLICIT

Destructed explicitly by predef::destruct.

Object.DESTRUCT_NO_REFS

Destructed due to running out of references.

Object.DESTRUCT_GC

Destructed by the garbage collector.

Object.DESTRUCT_CLEANUP

Destructed as part of the cleanup when the pike process exits. Occurs only if Pike has been compiled with the configure option --with-cleanup-on-exit. See note below.

Note

Objects are normally not destructed when a process exits, so _destruct functions aren't called then. Use atexit to get called when the process exits.

Note

Regarding destruction order during garbage collection:

If an object is destructed by the garbage collector, it's part of a reference cycle with other things but with no external references. If there are other objects with _destruct functions in the same cycle, it becomes a problem which to call first.

E.g. if this object has a variable with another object which (directly or indirectly) points back to this one, you might find that the other object already has been destructed and the variable thus contains zero.

The garbage collector tries to minimize such problems by defining an order as far as possible:

  • If an object A contains an lfun::_destruct and an object B does not, then A is destructed before B.

  • If A references B single way, then A is destructed before B.

  • If A and B are in a cycle, and there is a reference somewhere from B to A that is weaker than any reference from A to B, then A is destructed before B.

  • If a cycle is resolved according to the rule above by ignoring a weaker reference, and there is another ambiguous cycle that would get resolved by ignoring the same reference, then the latter cycle will be resolved by ignoring that reference.

  • Weak references (e.g. set with predef::set_weak_flag()) are considered weaker than normal references, and both are considered weaker than strong references.

  • Strong references are those from objects to the objects of their lexically surrounding classes. There can never be a cycle consisting only of strong references. (This means the gc never destructs a parent object before all children have been destructed.)

An example with well defined destruct order due to strong references:

class Super {class Sub {protectedvoid _destruct(){if(!Super::this)
        error ("My parent has been destructed!\n");}}
  Sub sub = Sub();protectedvoid _destruct(){if(!sub)
      werror ("sub already destructed.\n");}}

The garbage collector ensures that these objects are destructed in an order so that werror in Super is called and not error in Sub.

Note

When the garbage collector calls lfun::_destruct, all accessible non-objects and objects without _destruct functions are still intact. They are not freed if the _destruct function adds external references to them. However, all objects with lfun::_destruct in the cycle are already scheduled for destruction and will therefore be destroyed even if external references are added to them.

See also

lfun::create(), predef::destruct()


Method_equal

int_equal(mixedarg)

Description

Recursive equality callback.

Returns

Is expected to return 1 if the current object is equal to arg, and 0 (zero) otherwise.

Note

It's assumed that this function is side-effect free.

Note

Note that this function may return different values at different times for the same argument due to the mutability of the object.

See also

predef::equal(), lfun::`==()


Method_get_iterator

predef::Iterator_get_iterator(mixed ... args)

Description

Iterator creation callback.

Parameter args

Optional extra arguments as passed to get_iterator(). The implicit call from foreach() does not provide any arguments.

The returned predef::Iterator instance works as a cursor that references a specific item contained (in some arbitrary sense) in this one.

Note

It's assumed that this function is side-effect free.

See also

predef::Iterator, predef::get_iterator, predef::foreach()


Method_indices

array_indices(object|voidcontext, int|voidaccess)

Description

List indices callback.

Returns

Expected to return an array with the valid indices in the object.

Note

It's assumed that this function is side-effect free.

See also

predef::indices(), lfun::_values(), lfun::_types(), ::_indices()


Method_is_type

bool_is_type(stringbasic_type)

Description

Type comparison callback.

Called by the cast operator to determine if an object simulates a basic type.

Parameter basic_type

One of:

"array"
"float"
"function"
"int"
"mapping"
"multiset"
"object"
"program"
"string"
"type"
"void"
"zero"

The following five shouldn't occurr, but are here for completeness:

"lvalue"
"mapping_data"
"object storage"
"pike_frame"
"unknown"
Returns

Expected to return 1 if the object is to be regarded as a simulation of the type specified by basic_type.

Note

The argument is currently a string with the name of the type, but might in the future be a value of the type type.

Note

It's assumed that this function is side-effect free.


Method_iterator_index

optionalmixed_iterator_index()

Description

Called in Iterator objects by foreach (optional).

Returns

Returns the current index for an iterator, or UNDEFINED if the iterator doesn't point to any item. If this function is not present, the return value from lfun::_iterator_next() will be used.

If there's no obvious index set then the index is the current position in the data set, counting from 0 (zero).

See also

predef::iterator_index(), lfun::_iterator_next(), lfun::_iterator_prev(), lfun::_iterator_value()


Method_iterator_next

mixed_iterator_next()

Description

Called in Iterator objects by foreach.

Advances the iterator one step.

Iterators start at the position before the first element, and foreach calls this function repeatedly until it returns UNDEFINED.

Calling it again after it has returned UNDEFINED will typically cause it to restart the iteration with the first element (ie the start and end sentinel values are the same).

Returns

Returns UNDEFINED if there are no more elements in the iterator. Otherwise it may return any other value, which for convenience will be used as index and/or value in case there is no lfun::_iterator_index() and/or no lfun::_iterator_value().

Note

This is the only function that is required by the iterator API.

See also

predef::iterator_next(), lfun::_iterator_prev(), lfun::_iterator_index(), lfun::_iterator_value()


Method_iterator_prev

optionalmixed_iterator_prev()

Description

Step an iterator backwards.

Calling this function after it or _iterator_next() it has returned UNDEFINED will typically cause it to restart the iteration with the last element (ie the start and end sentinel values are the same).

Returns

Returns UNDEFINED if there are no more elements in the iterator. Otherwise it may return any other value, which for convenience may be used as index and/or value in case there is no lfun::_iterator_index() and/or no lfun::_iterator_value().

Note

This function is an optional part of the iterator API and is not called directly by the runtime.

See also

predef::iterator_prev(), lfun::_iterator_next(), lfun::_iterator_value(), lfun::_iterator_index()


Method_iterator_value

optionalmixed_iterator_value()

Description

Called in Iterator objects by foreach (optional).

Returns

Returns the current value for an iterator, or UNDEFINED if the iterator doesn't point to any item.

See also

predef::iterator_value(), lfun::_iterator_next(), lfun::_iterator_prev(), lfun::_iterator_index()


Method_m_add

void_m_add()

Description

Called by m_add().

See also

lfun::_m_delete(), lfun::_m_clear()


Method_m_clear

void_m_clear()

Description

Called by m_clear().

See also

lfun::_m_delete(), lfun::_m_add()


Method_m_delete

mixed_m_delete(mixedarg)

Description

Delete index callback.

See also

predef::m_delete()


Method_random

mixed_random(function(int(0..):string(8bit)) random_string, function(mixed:mixed) random)

Description

Called by random(). Typical use is when the object implements a ADT, when a call to this lfun should return a random member of the ADT or range implied by the ADT.

Parameter random_string

A RandomInterface()->random_string function that returns a string(8bit) of the specified length.

Parameter random

A RandomInterface()->random function.

See also

predef::random(), RandomInterface


Method_reverse

mixed_reverse(mixed ... options)

Description

Called by reverse().


Method_search

mixed_search(mixedneedle, mixed|voidstart, mixed ... extra_args)

Description

Search callback.

The arguments are sent straight from search(), and are as follows:

Parameter needle

Value to search for.

Parameter start

The first position to search.

Parameter extra_args

Optional extra arguments as passed to search().

See also

predef::search()


Method_serialize

void_serialize(objecto, function(mixed, string, type:void) serializer)

Description

Dispatch function for Serializer.serialize().

Parameter o

Object to serialize. Always a context of the current object.

Parameter serializer

Function to be called once for every variable to serialize.

The serializer function expects to be called with three arguments:

value - The value of the symbol.

symbol - The symbol name.

symbol_type - The type of the symbol.

Note

A default implementation of lfun::_serialize() and lfun::_deserialize() is available in Serializer.Serializable.

See also

lfun::_deserialize(), Serializer.serialize(), Serializer.Serializable()->_serialize()


Method_size_object

int_size_object()

Description

Debug.size_object() callback.

Returns

Returns an approximation of the memory use in bytes for the object.

See also

Debug.size_object(), lfun::_sizeof()


Method_sizeof

int_sizeof()

Description

Size query callback.

Called by predef::sizeof() to determine the number of elements in an object. If this function is not present, the number of public symbols in the object will be returned.

Returns

Expected to return the number of valid indices in the object.

Note

It's assumed that this function is side-effect free.

See also

predef::sizeof()


Method_sprintf

string_sprintf(intconversion_type, mapping(string:int)|voidparams)

Description

Sprintf callback.

This method is called by predef::sprintf() to print objects. If it is not present, printing of the object will not be supported for any conversion-type except for the %O-conversion-type, which will output "object".

Parameter conversion_type

One of:

'b'

Signed binary integer.

'd'

Signed decimal integer.

'u'

Unsigned decimal integer.

'o'

Signed octal integer.

'x'

Lowercase signed hexadecimal integer.

'X'

Uppercase signed hexadecimal integer.

'c'

Character. If a fieldsize has been specified this will output the low-order bytes of the integer in network byte order.

'f'

Float.

'g'

Heuristically chosen representation of float.

'G'

Like %g, but uses uppercase E for exponent.

'e'

Exponential notation float.

'E'

Like %e, but uses uppercase E for exponent.

's'

String.

'O'

Any value (debug style).

't'

Type of the argument.

Parameter params

Conversion parameters. The following parameters may be supplied:

"precision" : int

Precision.

"width" : int

Field width.

"flag_left" : int(1)

Indicates that the output should be left-aligned.

"indent" : int

Indentation level in %O-mode.

Returns

Is expected to return a string describing the object formatted according to conversion_type.

Note

_sprintf() is currently not called for the following conversion-types:

'F'

Binary IEEE representation of float (%4F gives single precision, %8F gives double precision.)

Note

This function might be called at odd times, e.g. before lfun::create has been called or when an error has occurred. The reason is typically that it gets called when a backtrace is being formatted to report an error. It should therefore be very robust and not make any assumptions about its own internal state, at least not when conversion_type is 'O'.

Note

It's assumed that this function is side-effect free.

See also

predef::sprintf()


Method_sqrt

mixed_sqrt()

Description

Called by sqrt().

See also

sqrt()


Method_sqrt

mixed_sqrt()

Description

Called by sqrt when the square root of an object is requested.

Note

_sqrt is not a real lfun, so it must not be defined as static.

See also

predef::sqrt()


Method_types

array_types(object|voidcontext, int|voidaccess)

Description

List types callback.

This callback is typically called via predef::types().

Returns

Expected to return an array with the types corresponding to the indices returned by lfun::_indices().

Note

It's assumed that this function is side-effect free.

Note

predef::types() was added in Pike 7.9.

See also

predef::types(), lfun::_indices(), lfun::_values(), ::_types()


Method_values

array_values(object|voidcontext, int|voidaccess)

Description

List values callback.

Returns

Expected to return an array with the values corresponding to the indices returned by lfun::_indices().

Note

It's assumed that this function is side-effect free.

See also

predef::values(), lfun::_indices(), lfun::_types(), ::_values()


Method`!

int`!()

Description

Logical not callback.

Returns

Returns non-zero if the object should be evaluated as false, and 0 (zero) otherwise.

Note

It's assumed that this function is side-effect free.

See also

predef::`!()


Method`%

mixed`%(zero ... args)

Description

Left side modulo callback.

Note

It's assumed that this function is side-effect free.

See also

lfun::``%(), predef::`%()


Method`&

mixed`&(zero ... args)

Description

Left side bitwise and/intersection callback.

Note

It's assumed that this function is side-effect free.

See also

lfun::``&(), predef::`&()


Method`()

mixed`()(zero ... args)

Description

Apply callback.

See also

predef::`()


Method`*

mixed`*(zero ... args)

Description

Left side multiplication/repetition/implosion callback.

Note

It's assumed that this function is side-effect free.

See also

lfun::``*(), predef::`*()


Method`**

object|int|float`**(int|float|objectexp)

Description

Called by predef::`**().

See also

predef::`**(), lfun::``**()


Method`+

mixed`+(zeroarg)

Description

Left side addition/concatenation callback.

This is used by predef::`+. It's called with the argument that follow this object in the argument list of the call to predef::`+. The returned value should be a new instance that represents the addition/concatenation between this object and the argument.

Note

It's assumed that this function is side-effect free.

Note

In versions of Pike prior to 8.1.10 this function could get called with multiple arguments.

See also

lfun::``+(), lfun::`+=(), predef::`+()


Method`+=

this_program`+=(zeroarg)

Description

Destructive addition/concatenation callback.

This is used by predef::`+. It's called with the argument that follow this object in the argument list of the call to predef::`+. It should update this object to represent the addition/concatenation between it and the argument. It should always return this object.

Note

This function should only be implemented if lfun::`+() also is. It should only work as a more optimized alternative to that one, for the case when it's safe to change the object destructively and use it directly as the result.

Note

This function is not an lfun for the += operator. It's only whether or not it's safe to do a destructive change that decides if this function or lfun::`+() is called; both the + operator and the += operator can call either one.

Note

In versions of Pike prior to 8.1.10 this function could get called with multiple arguments.

See also

lfun::`+(), predef::`+()


Method`-

mixed`-(void|zeroarg)

Description

Negation and left side subtraction/set difference callback.

This is used by predef::`-. When called without an argument the result should be a new instance that represents the negation of this object, otherwise the result should be a new instance that represents the difference between this object and arg.

Note

It's assumed that this function is side-effect free.

See also

lfun::``-(), predef::`-()


Method`->

mixed`->(stringindex, object|voidcontext, int|voidaccess)

Description

Arrow index callback.

Parameter index

Symbol in context to access.

Parameter context

Context in the current object to start the search from. If UNDEFINED or left out, this_program::this is to be be used (ie start at the current context and ignore any overloaded symbols).

Parameter access

Access permission override. One of the following:

0

See only public symbols.

UNDEFINED
1

See protected symbols as well.

Returns

Returns the value at index if it exists, and UNDEFINED otherwise.

Note

It's assumed that this function is side-effect free.

See also

predef::`->(), ::`->()


Method`->=

mixed`->=(stringindex, zerovalue, object|voidcontext, int|voidaccess)

Description

Atomic get and set arrow index callback.

Parameter index

Symbol in context to change the value of.

Parameter value

The new value.

Parameter context

Context in the current object to index.

If UNDEFINED or left out, this_program::this is to be used (ie start at the current context and ignore any overloaded symbols).

Parameter access

Access permission override. One of the following:

0

See only public symbols.

UNDEFINED
1

See protected symbols as well.

This function is to set the value at symbol index of the current object to value.

Returns

Returns the previous value at symbol index of the current object.

Note

In Pike 8.0 and earlier the return value of this function was ignored.

See also

predef::`->=(), ::`->=(), lfun::`[]=(), lfun::_atomic_get_set()


Method`/

mixed`/(zero ... args)

Description

Left side division/split callback.

Note

It's assumed that this function is side-effect free.

See also

lfun::``/(), predef::`/()


Method`<

bool`<(mixedarg)

Description

Less than test callback.

Note

It's assumed that this function is side-effect free.

See also

predef::`<()


Method`<<

mixed`<<(zeroarg)

Description

Left side left shift callback.

Note

It's assumed that this function is side-effect free.

See also

lfun::``<<(), predef::`<<()


Method`==

bool`==(mixedarg)

Description

Equivalence test callback.

Returns

Is expected to return 1 if the current object is equivalent to arg (ie may be replaced with arg, with no semantic differences (disregarding the effects of destruct())), and 0 (zero) otherwise.

Note

If this is implemented it may be necessary to implement lfun::__hash too. Otherwise mappings may hold several objects as indices which are duplicates according to this function. This may also affect various other functions that use hashing internally, e.g. predef::Array.uniq.

Note

It's assumed that this function is side-effect free.

Note

It's recommended to only implement this function for immutable objects, as otherwise stuff may get confusing when things that once were equivalent no longer are so, or the reverse.

See also

predef::`==(), lfun::__hash


Method`>

bool`>(mixedarg)

Description

Greater than test callback.

Note

It's assumed that this function is side-effect free.

See also

predef::`>()


Method`>>

mixed`>>(zeroarg)

Description

Left side right shift callback.

Note

It's assumed that this function is side-effect free.

See also

lfun::``>>(), predef::`>>()


Method`[..]

mixed`[..](zerolow, intlow_bound_type, zerohigh, inthigh_bound_type)

Description

Subrange callback.

Note

It's assumed that this function is side-effect free.

See also

predef::`[..]


Method`[]

mixed`[](zeroarg1, zero|voidarg2)

Description

Indexing callback.

For compatibility, this is also called to do subranges unless there is a `[..] in the class. See predef::`[..] for details.

Note

It's assumed that this function is side-effect free.

See also

predef::`[](), predef::`[..]


Method`[]=

mixed`[]=(zeroindex, zerovalue, object|voidcontext, int|voidaccess)

Description

Atomic get and set index callback.

Parameter index

Index to change the value of.

Parameter value

The new value.

Parameter context

Context in the current object to index.

If UNDEFINED or left out, this_program::this is to be used (ie start at the current context and ignore any overloaded symbols).

Parameter access

Access permission override. One of the following:

0

See only public symbols.

UNDEFINED
1

See protected symbols as well.

This function is to set the value at index index of the current object to value.

Returns

Returns the previous value at index index of the current object.

Note

In Pike 8.0 and earlier the return value of this function was ignored.

See also

predef::`[]=(), lfun::`->=(), lfun::_atomic_get_set()


Method`^

mixed`^(zero ... args)

Description

Left side exclusive or callback.

Note

It's assumed that this function is side-effect free.

See also

lfun::``^(), predef::`^()


Method``%

mixed``%(zero ... args)

Description

Right side modulo callback.

Note

It's assumed that this function is side-effect free.

See also

lfun::`%(), predef::`%()


Method``&

mixed``&(zero ... args)

Description

Right side bitwise and/intersection callback.

Note

It's assumed that this function is side-effect free.

See also

lfun::`&(), predef::`&()


Method``*

mixed``*(zero ... args)

Description

Right side multiplication/repetition/implosion callback.

Note

It's assumed that this function is side-effect free.

See also

lfun::`*(), predef::`*()


Method``**

object|int|float``**(int|float|objectbase)

Description

Called by predef::`**().

See also

predef::`**(), lfun::`**()


Method``+

mixed``+(zeroarg)

Description

Right side addition/concatenation callback.

This is used by predef::`+. It's called with the sum of the arguments that precede this object in the argument list of the call to predef::`+. The returned value should be a new instance that represents the addition/concatenation between the argument and this object.

Note

It's assumed that this function is side-effect free.

Note

In versions of Pike prior to 8.1.10 this function could get called with multiple arguments.

See also

lfun::`+(), predef::`+()


Method``-

mixed``-(zeroarg)

Description

Right side subtraction/set difference callback.

This is used by predef::`-. The result should be a new instance that represents the difference between arg and this object.

Note

It's assumed that this function is side-effect free.

See also

lfun::`-(), predef::`-()


Method``/

mixed``/(zero ... args)

Description

Right side division/split callback.

Note

It's assumed that this function is side-effect free.

See also

lfun::`/(), predef::`/()


Method``<<

mixed``<<(zeroarg)

Description

Right side left shift callback.

Note

It's assumed that this function is side-effect free.

See also

lfun::`<<(), predef::`<<()


Method``>>

mixed``>>(zeroarg)

Description

Right side right shift callback.

Note

It's assumed that this function is side-effect free.

See also

lfun::`>>(), predef::`>>()


Method``^

mixed``^(zero ... args)

Description

Right side exclusive or callback.

Note

It's assumed that this function is side-effect free.

See also

lfun::`^(), predef::`^()


Method``|

mixed``|(zero ... args)

Description

Right side bitwise or/union callback.

Note

It's assumed that this function is side-effect free.

See also

lfun::`|(), predef::`|()


Method`|

mixed`|(zero ... args)

Description

Left side bitwise or/union callback.

Note

It's assumed that this function is side-effect free.

See also

lfun::``|(), predef::`|()


Method`~

mixed`~()

Description

Complement/inversion callback.

Note

It's assumed that this function is side-effect free.

See also

predef::`~()


Methodcast

mixedcast(stringrequested_type)

Description

Value cast callback.

Parameter requested_type

Type to cast to.

Returns

Expected to return the object value-casted (converted) to the type described by requested_type.

Note

The argument is currently a string with the name of the type, but might in the future be a value of the type type.

Note

Currently casting between object types is a noop.

Note

If the returned value is not deemed to be of the requested type a runtime error may be thrown.

Note

It's assumed that this function is side-effect free.


Methodcreate

void lfun:create(__unknown__ ... args)

Description

Object creation callback.

This function is called right after lfun::__INIT().

args are the arguments passed when the program was called.

Note

If there exists an implicitly created lfun::__create__() its arguments will be prepended to args (affecting the prototype for lfun::create()), and a call to it will be prepended to the code of lfun::create().

Note

In Pike 8.0 and earlier the code equivalent to lfun::__create__() was inlined at the beginning of lfun::create().

Note

If this function does not exist, but lfun::__create__() does, it will instead be called directly.

See also

lfun::__create__(), lfun::__INIT(), lfun::_destruct()

8.2. ::

Namespace ::

Description

Symbols implicitly inherited from the virtual base class.

These symbols exist mainly to simplify implementation of the corresponding lfuns.

See also

lfun::


Method_annotations

array_annotations(object|voidcontext, int|voidaccess, bool|voidrecursive)

Description

Called by annotations()

Parameter context

Inherit in the current object to return the annotations for. If UNDEFINED or left out, this_program::this should be used (ie start at the current context and ignore any overloaded symbols).

Parameter access

Access permission override. One of the following:

0

See only public symbols.

UNDEFINED
1

See protected symbols as well.

Parameter recursive

Include nested annotations from the inherits.

Builtin function to list the annotations (if any) of the identifiers of an object. This is useful when lfun::_annotations has been overloaded.

See also

annotations(), lfun::_annotations()


Method_indices

array(string) _indices(object|voidcontext, int|voidaccess)

Parameter context

Context in the current object to start the list from. If UNDEFINED or left out, this_program::this will be used (ie start at the current context and ignore any overloaded symbols).

Parameter access

Access permission override. One of the following:

0

See only public symbols.

UNDEFINED
1

See protected symbols as well.

Builtin function to list the identifiers of an object. This is useful when lfun::_indices has been overloaded.

See also

::_values(), ::_types(), ::`->()


Method_types

array_types(object|voidcontext, int|voidaccess)

Parameter context

Context in the current object to start the list from. If UNDEFINED or left out, this_program::this will be used (ie start at the current context and ignore any overloaded symbols).

Parameter access

Access permission override. One of the following:

0

See only public symbols.

UNDEFINED
1

See protected symbols as well.

Builtin function to list the types of the identifiers of an object. This is useful when lfun::_types has been overloaded.

See also

::_indices(), ::_values(), ::`->()


Method_values

array_values(object|voidcontext, int|voidaccess)

Parameter context

Context in the current object to start the list from. If UNDEFINED or left out, this_program::this will be used (ie start at the current context and ignore any overloaded symbols).

Parameter access

Access permission override. One of the following:

0

See only public symbols.

UNDEFINED
1

See protected symbols as well.

Builtin function to list the values of the identifiers of an object. This is useful when lfun::_values has been overloaded.

See also

::_indices(), ::_types(), ::`->()


Method`->

mixed`->(stringindex, object|voidcontext, int|voidaccess)

Description

Builtin arrow operator.

Parameter index

Symbol in context to access.

Parameter context

Context in the current object to start the search from. If UNDEFINED or left out, this_program::this will be used (ie start at the current context and ignore any overloaded symbols).

Parameter access

Access permission override. One of the following:

0

See only public symbols.

UNDEFINED
1

See protected symbols as well.

This function indexes the current object with the string index. This is useful when the arrow operator has been overloaded.

See also

::`->=()


Method`->=

mixed`->=(stringindex, mixedvalue, object|voidcontext, int|voidaccess)

Description

Builtin atomic arrow get and set operator.

Parameter index

Symbol in context to change the value of.

Parameter value

The new value.

Parameter context

Context in the current object to start the search from. If UNDEFINED or left out, this_program::this will be used (ie start at the current context and ignore any overloaded symbols).

Parameter access

Access permission override. One of the following:

0

See only public symbols.

UNDEFINED
1

See protected symbols as well.

This function indexes the current object with the string index, and sets it to value. This is useful when the arrow set operator has been overloaded.

Returns

Returns the previous value at index index of the current object.

See also

::`->()

8.3. continue::

Namespace continue::

Description

Symbols specific for restartable functions.

See also

this_function, Restartable functions


Constantthis_function

constantthis_function

Description

This symbol is only valid in restartable functions and evaluates to the current restartable function (ie the function that will continue the current function from the next restart point (ie next yield() or continue return). For generator functions this is the same value as the value that was returned by the "outer" (ie generator) function.

This differs from predef::this_function which evaluates to the "outer" function.

See also

predef::this_function, predef::this, predef::this_object()