IndexingOverview
Indexing is the operation that retrieves a specified value contained within another datatype, such as an array, mapping or object.Pike has three indexing operators:
- [ ]
- __-> __
- __.__For values other than objects the operators perform the same operation.The '[]' operator can index with any pike value, and uses the `[]() lfun in
objects.The '->' operator is for indexing with identifiers, and uses the `->() lfun
in objects.The '.' operator is also for indexing with identifiers, and uses the `[]()
lfun in objects. In Pike 7.6 and earlier this indexing operator was only
supported for constant values, and the index operation was performed at
compile-time. In Pike 7.7 and later the operator is also supported for non
constant expressions, in which case the indexing operation will be performed
at runtime.The main place where the difference between '->' and '.' shows up
is for directory modules, where '->' indexes the object
that implements the module, and '[]' and '.' index the module itself. Huh?See AlsoFinding Functions by Name
Powered by PikeWiki2
|
|