Re: bug when using foreach with references?
| From: | Rasmus Lerdorf | Date: | Thu, 22 Oct 2009 15:33:53 +0000 |
| Subject: | Re: bug when using foreach with references? | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-45870@lists.php.net to get a copy of this message | ||
Richard K Miller wrote:
> On Oct 22, 2009, at 1:42 AM, Antony Dovgal wrote:
>
>> On 22.10.2009 05:37, Richard K Miller wrote:
>>> Is this a bug in PHP?
>>
>> Search the bug DB before asking such questions.
>>
>> http://bugs.php.net/bug.php?id=29992
>> http://bugs.php.net/bug.php?id=39307
>> http://bugs.php.net/bug.php?id=40065
>> http://bugs.php.net/bug.php?id=40654
>> http://bugs.php.net/bug.php?id=41603
>> http://bugs.php.net/bug.php?id=43501
>> http://bugs.php.net/bug.php?id=43806
>> http://bugs.php.net/bug.php?id=43988
>> http://bugs.php.net/bug.php?id=47388
>>
>
> Antony,
>
> I've seen some of those, though not all, but thought I'd bring it up for
> discussion. I've appreciated the thoughtful responses, for example from
> Marco Tabini, to help explain this. It still doesn't quite make sense to
> me.
>
> Doesn't it seem alarming that there are so many bug reports on this
> issue, even if from an internals perspective it makes sense to you?
It is one of these things that make perfect sense when you think about
it a little bit. Yes, it catches some people, just like strpos()
returning character position 0 on a first-char match catches some
people. There is no way to fix things like these without completely
breaking things. If we had strpos not use 0-based string positions or
if we arbitrarily broke references after loops, all sorts of other
things would start breaking and no longer make sense.
-Rasmus