I'm talking about the traditional for construct on which the PHP version is based. In PHP, that part of the for construct is somewhat meaningless. I'm saying that it is not as programmatically powerful as it could be. I understand how it currently works (what you have been stating), and I am saying that you should consider a change.
LingWitt,
As illustrated, we're not considering a change because what you're suggesting contradicts fundamental building blocks of PHP: no need to declare variables, and the fact that there's only one scope. There's nothing special in for loops, not in PHP, and not even in the early C++ implementations. In recent C++ implementations, variable declarations in the for statement are considered to belong to the code block inside the for loop, but it didn't even use to be that way in earlier implementations of C++ (e.g., Visual C++ 6). The point is that it all boils down to the issue of declaring variables, and variable scope in general, which is completely different in PHP from the way it is in C or C++. Making an exception with for loop makes absolutely no sense at all, as it's completely inconsistent with the way PHP behaves with code blocks in general.
In PHP, variables are declared when you first use them. They live for as long as the current function lives - there's only one scope in PHP, and that's the function scope. Both of these are not going to change, as again, they're a part of the basics that make PHP what it is.
Zeev
-- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php