[fpc-pascal] sort procedure of T(FP)List

Marc Santhoff M.Santhoff at t-online.de
Tue May 2 19:46:09 CEST 2006


Hi,

i wonder why the declaration of the comparing function of list objects
is the way it is:

TListSortCompare = function (Item1, Item2: Pointer): Integer;

Since I am writing a class that sorts a list it owns depending on
another property naming the property of the list items for sorting, I
would like to have it made a "procedure of object":

TListSortCompare = function (Item1, Item2: Pointer): Integer of object;

I'm dealing with lists of files and directories that should get sorted
by name, date, ...
If the comparing function is a plain non object function I have to make
some sort of unit global variable or the like for telling it, what
property is the sort criteria. I don't like this design, although in
this case there is only one soritng process at a time.

Is this a concession imposed by Delphi compatibility?

(If you can suggest a better strategy for using this stuff, please do.)

TIA;
Marc





More information about the fpc-pascal mailing list