|
Posted by Steve on 01/04/08 17:54
"Jerry Stuckle" <jstucklex@attglobal.net> wrote in message
news:6KmdnRk59_ChqOPanZ2dnUVZ_jydnZ2d@comcast.com...
> adam.timberlake@gmail.com wrote:
>> I was reading the following article yesterday:
>> http://www.talkphp.com/vbarticles.php?do=article&articleid=41&title=using-the-internal-array-pointers-to-access-elements-in-arrays
>>
>> What struck me while reading it was how very little we hear about the
>> array internal pointers !! I've been in PHP now for a good 2 years,
>> and I've never heard these little guys mentioned before.
>>
>> My question is... what do you use internal pointers for, and why?
>>
>
> I use them a fair amount. Sometimes you need to run through an array, and
> foreach() just doesn't do what you need (or makes the code more
> complicated).
lol. you get on to the op for multiposting and tell him you've answered his
question here. this is an answer?! your only good point was not
multiposting. however, i'm sure no one in alt.comp.lang.php will miss this
'answer'...as it does nothing for anyone.
why not tell the op *how* you use them and give an example of *how* your use
does something that foreach doesn't (or doesn't easily) do? hell, i'd be
very interested in THAT myself. i can't think of a situation that would
apply.
a better answer is that most languages have these constructs. typically in
more formal languages there is an iterator interface whereby you can can
impliment into a strongly typed collection object that will contain only
those types of items. your implimenting object/collection keeps track of the
'pointer' spoken about in the article and exposes those standard pointer
functions. implementing said interface allows the language to iterate, i.e.
foreach, the items even though you may have heavily customized your
collection. i would assume that having said little known pointer functions
would allow forward compatibility should php start to become more strongly
data typed in future versions.
AND, funny how the writer of the article uses the word internal 'pointer'.
count how many times. i couldn't be laughing harder.
Navigation:
[Reply to this message]
|