[fpc-devel] Parameters must match exactly?
Flávio Etrusco
flavio.etrusco at gmail.com
Fri May 14 16:50:08 CEST 2010
On Fri, May 14, 2010 at 11:45 AM, Graeme Geldenhuys
<graemeg.lists at gmail.com> wrote:
> Hi,
>
> I tried using FPC 2.5.1 today to see how compatible is our application with
> it compared to FPC 2.4.1
>
> I got stacks of the following errors. Why is this change forced in FPC
> 2.5.1? TBulkInvoiceRateListForm class is a descendant of TfpgWindowBase so
> there should be a problem. I don't understand. :-/
>
> -------------
> frm_bulkinvoiceratelist.pas(84,77) Error: Call by var for arg no. 2 has to
> match exactly: Got "TBulkInvoiceRateListForm" expected "TfpgWindowBase"
> fpg_base.pas(2207,31) Hint: Found declaration:
> TfpgApplicationBase.CreateForm(TComponentClass,out TfpgWindowBase);
> frm_bulkinvoiceratelist.pas(307) Fatal: There were 1 errors compiling
> module, stopping
> --------------------
>
>
> To get my code to compile again, I have to change the following code from
>
> fpgApplication.CreateForm(TBulkInvoiceRateListForm, BulkDiscountListForm);
>
> ...to this...
>
> fpgApplication.CreateForm(TBulkInvoiceRateListForm,
> TfpgWindowBase(BulkDiscountListForm));
>
> Now I have to include ugly casts all over the place. :-(
>
>
> I got similar issues with TStrings and TStringList. TStringList is a
> descendant of TStrings, but I can't pass a TStringList type as a parameter
> to a method declared with TStrings.
>
>
> Maybe I don't understand the var parameter correctly (but haven't tested to
> see what happens if I remove var from parameter list). If I have a class
> instance, when should I pass it to a method or function/procedure as var
> and when don't I need to use var parameters?
>
>
>
> Regards,
> - Graeme -
>
> --
I thought this feature was an improvement over Delphi too. But IIRC
the argumentation was that it generated confusion, as somebody could
think a reintroduced method would be invoked instead of the base one.
I guess there was some other more compelling reason, but I can't
remember right now, but I'm positive this was already brought up on
the list.
Best regards,
Flávio
More information about the fpc-devel
mailing list