Vinzent Hoefler wrote:
Suppose, the list items have a property "Owner" and the iterator calls some method that says "Owner.Delete (self);" somewhere. How's the compiler supposed to detect that?

It can't. In general, all references to the (iterator) list need to be "const" at this time, but I guess it's impossible to prove whether some reference is a reference to the particular list being iterated. Let alone a function that "might" be called by an iterating for-in loop.

In some languages, this problem is circumvented by creating a copy of the list before iterating the set, but I don't think that this is a viable solution for Pascal (or any compiled language, for that matter).

That solution seems too costly to me.

Micha
_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply via email to