On Monday 26 October 2009, Micha Nelissen wrote: > Vinzent Höfler wrote: > > At first, "const function" would tell us that the function does not > > change the object in any way, right? > > What is "the object"?
In that case, the list, of course. > Usually there are 2 objects: the list (TList > e.g.) and the object being iterated, e.g. TList.Objects[I]. Those > referenced objects can be volatile, the const-ness only applies to > the TList. Yes, that's what I thought. > Ideally the iterator state and the state of the items > iterated over are separated. (Maybe this is not so with e.g. > TStringList). 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? 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). Vinzent. _______________________________________________ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel