On Mon, 21 Mar 2016, David Jenkins wrote:

I just ran across the change that checks Sorted at beginning of find and exits if Sorted = False. This has caused some problems for us

a) We have lists that are sorted manually and we'd like to continue keeping them sorted manually (and be able to call .insert()). This means not setting the sorted flag. But without setting 'sorted' we can no longer use find. We are sharing code between VCL and FPC - delphi compatibility has been broken.

b) The change, in my opinion, hasn't solved the unpredictable response problem. There is still nothing to indicate to a caller that they have called the function inappropriately i.e. they do not know why find has returned false.

Furthermore the documentation also indicates that if false is returned then 'Index' will contain the position where the string should be inserted. Index used to at least be within the range of FCount or 0. Now the value 'Index' is even more indeterminte as the code exits before Index has been set to anything. It has gone from possibly placing a string at a wrong location to possibly causing a crash with index out of range.

It could be argued whether this is worse but it certainly doesn't seem to have made the situation any better for people blindly misusing Find an unsorted list - while at the same time breaking Delphi compatibility and the option to manually keep lists sorted.

Thoughts?

We can introduce a property which disables the check, if you want.

Michael.
_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

Reply via email to