[fpc-pascal] Forward declarations
Tomas Hajny
XHajT03 at hajny.biz
Fri Dec 23 09:46:07 CET 2011
On Fri, December 23, 2011 07:24, Jürgen Hestermann wrote:
> Timothy Groves schrieb:
>> Can anyone think of a situation in which you would *have* to use
>> forward declared functions? I'm trying to come up with an example for
>> such for my book, and I am drawing a blank.
>>
>
> Well, maybe this one:
>
> -------------------------------------------------------------------
> type SorterProcType = function (String1,String2 : shortstring) :
> boolean;
> function CompareIt1(String1,String2 : shortstring) : boolean; forward;
> function CompareIt2(String1,String2 : shortstring) : boolean; forward;
> function CompareIt3(String1,String2 : shortstring) : boolean; forward;
> const SortCriteria : SortProcType = CompareIt1;
>
> -------------------------------------------------------------------
>
> I don't know of another way that you can use one of the "CompareIt1/2/3"
> functions in the const declaration for "SortCriteria" (but maybe there
> is one).
In this case, you could directly include the implementation with the
CompareIt* declaration (unless CompareIt1 needs to access SortCriteria
too, of course - that would change the picture).
Tomas
More information about the fpc-pascal
mailing list