In Python, too, you can change the loop variable; but every time execution goes back to the top of the loop, the variable takes on the next value it _would have_ taken, no matter what you've done to it in the meantime. (If I remember right.) Kind of a handy combination -- as long as you remember how it works. But this proviso presumably applies to _any_ implementation of loop variables, except one that relieves your memory of the burden by raising an error if you even try to change the variable. That's safest, but kind of . . . paternalistic, yes?

Charles


On Jul 31, 2005, at 1:20 PM, Mark Wieder wrote:

Jon-

Sunday, July 31, 2005, 5:59:01 AM, you wrote:

J> It has been considered a bug, and flagged for the programmer, in Delphi J> for years. I don't see how it can be considered anything else. Now as J> to whether it is a bug that is reported in Rev with an error message,
J> that is a different story.

I wasn't aware that Delphi even *had* a "for each" element construct,
but then I haven't kept up with Delphi since v6.0 or so. Now that I've
googled it, I see that Borland added foreach support to Delphi 2005.
The documentation, though, clearly states that the loop indices are
provided as read-only references only and cannot be modified. Works
the same way in C#, in case you're interested.

Since this is a brand-new addition to Delphi, I'm not sure what you're
referring to in "has been considered a bug...for years". Nor how this
can be considered a bug, since it's clearly documented.

Personally, I prefer either the Perl or PHP implementations, where
you're free to use and modify the element since it's separate from the
loop index. Messing with a loop index is always a Bad Idea.
Interestingly, in Perl changing the loop element changes the original
referenced element, while in PHP the original value is unchanged.

--
-Mark Wieder
 [EMAIL PROTECTED]

_______________________________________________
use-revolution mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


_______________________________________________
use-revolution mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution

Reply via email to