>
> No chance.  No .ini settings, and I still maintain it is inconsistent.
>
> So, if I write this:
>
> $a = array(1);
> $b = 0;
> $c = &$b;
> $c = $a[0];
>
> Would you agree that $b should be 1 at this point?  If so, just because
> I rewrite that code like this:
>
> $a = array(1);
> $b = 0;
> $c = &$b;
> foreach($a as $c);
>
> Now you are arguing that $b should not be 1?
>
> The two pieces of code are identical and since we do not have a block
> scope and there is no syntax for explicitly indicating that $c is
> somehow a different $c or that we should wipe out the $c that existed
> before the foreach, I can see no sane reason to break the language for
> this case.
>
> And I don't see how your prev/next stuff has anything to do with this.
>
> -Rasmus

Rasmus,


> $a = array(1);
> $b = 0;
> $c = &$b;
> foreach($a as $c);
> Now you are arguing that $b should not be 1?
> The two pieces of code are identical

It's just a nightmare example. I wonder have you ever see anything like this 
in real life?
Could you please let me see it too, for example in code.google.com?
If you cann't, what are you fighting for?
Interestingly, how many people will consider the code sample you 
demonstrated ugly...
How many sporadic problems were already created and will be created just 
beacause
of this unclear behavior of foreach?

> And I don't see how your prev/next stuff has anything to do with this.


Ok. What my stuff has to do with this is there:
If prev/next were consistent with foreach, they would return first/last 
element of the
array respectively as soon as they reached the boundary. But no! They return 
FALSE.

Please have a look at this page
http://www.php.net/manual/en/control-structures.foreach.php

It's where you can find the following:
------------------------------------------------------------------------------
You may have noticed that the following are functionally identical:
<?php
$arr = array("one", "two", "three");
reset($arr);
while (list(, $value) = each($arr)) {
    echo "Value: $value<br />\n";
}

foreach ($arr as $value) {
    echo "Value: $value<br />\n";
}
?>
------------------------------------------------------------------------------

why not to make while (list(, &$value) = each($arr)) identical to foreach 
($arr as &$value) ?
It would make the language more consistent.


Meanwhile I see that php core developers and Evangelist propose the way of 
evolving difficulties.
For example, I used split() for many many years. Now it throws a warning and 
it appears
that this function will be removed soon. I have to rewrite all my scripts 
and replace
this function with pcreXXXX one and make sure that pcre extension is 
built-in everywhere. So BC is
broken in an ugly and a very unpleasant way.
Many php developers who count on split() are simply ignored. Like me, they 
have to
spend their time for monkey work. Nobody asked for such changes! 
Difficulties are created in
a steady place.
On the other hand, people are experiencing difficulties with an important 
function (php operator)
because it's behaviour is unclear/unexpected/nonintuitive. They all are 
asking
for the change, but what? Right - they are ignored. Instead, new arguments 
and ugly samples
will demonstrate us php developers that we are just fools and have plenty of 
times.

Best regards,
JV 



-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to