[fpc-pascal] question on docs

ppadilcdx at gmail.com ppadilcdx at gmail.com
Mon Oct 21 00:17:55 CEST 2024


Just tried to compile a short program with that definition of compare: TCompareFunc, and that is the wrong type for TFPGList<String> in my program (yes there is a better class for strings but I just wanted a quick example program to compile). FPC error message says it wants:
function(const ShortString;const ShortString):LongInt,
so only two non-pointer input parameters.  Must be another definition somewhere.

> On Oct 20, 2024, at 2:38 PM, Peter B via fpc-pascal <fpc-pascal at lists.freepascal.org> wrote:
> 
> On 20/10/2024 22:17, ppadilcdx--- via fpc-pascal wrote:
>> I’m a little confused by some references in the docs. Hopefully I can explain it clearly.
>> 
>> Looking at TFPGList in fgl. The Sort method refers to a TCompareFunc (it does not link to its definition). TFPGList says it’s methods are the same as TFPSList or classes.TFPList. So looking in these two other classes their Sort methods refer to TFPSListCompareFunc (in fgl) and TListSortCompare (in classes), respectively.
>> 
>> type TListSortCompare = function(
>>   Item1: Pointer;
>>   Item2: Pointer
>> ):Integer;
>> 
>> type TFPSListCompareFunc = function(
>>   Key1: Pointer;
>>   Key2: Pointer
>> ):Integer of object;
>> 
>> Two questions.
>> 1) Should TCompareFunc in TFPGList.Sort be one of the above types, or is there another definition somewhere?
>> 2) What is an “Integer of object” in TFPSListCompareFunc? (I expect it to be a typo but then I’m fairly new to free pascal so I might have missed the memo.)
>> 
>> Thanks,
>> Pete
>> 
>> _______________________________________________
>> fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
>> https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
> 
> For question 1, I find the definition of TCompareFunc here
> https://www.freepascal.org/docs-html/fcl/bufdataset/tcomparefunc.html
> 
> 
> 
> 
> _______________________________________________
> fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
> https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal



More information about the fpc-pascal mailing list