|
Posted by Steve on 04/12/07 14:02
"Toby A Inkster" <usenet200703@tobyinkster.co.uk> wrote in message
news:ivg1f4-4kp.ln1@ophelia.g5n.co.uk...
| Vince Morgan wrote:
| > Toby A Inkster wrote:
| >
| >> It's not a bug -- it's a "feature". Internally, arrays in PHP have a
| >> "pointer" (not in the C sense of the word) which points at the
"current"
| >
| > Why not in the "C sense"?
|
| A pointer in the C sense of the word is (more or less) an exact memory
| address for a piece of data.
|
| The internal pointer in a PHP array has a far more ethereal nature.
| Exactly how it works is an enigma wrapped in a riddle and shrouded by
| mystery. We don't have direct access to the pointer, but can see its
| ghostly effects in the list of functions I mentioned in my previous
| post.
ethereal?
let's say an enumerable object inherits an 'ienumerable' class. that
interface simply has a getEnumerator() function which php calls natively
when the code uses things like foreach(). getEnumerator() returns an
'ienumerator' object that defines the reset(), each(), key(), etc..
for all of that, ienumerator only has 2 variables. one for the array of
items, and one representing the current index. reset() just sets the index
to 0, each() increments, etc., etc.. none of that is brain surgurery and is
a common practice in object C, C++, VB, etc. whenever you want to strongly
type your own 'collection' to speed things up and enforce your variables'
integrity a bit more. it's not mysterious in any way.
:)
[Back to original message]
|