[fpc-devel] Parameters must match exactly?

Florian Klaempfl florian at freepascal.org
Tue May 18 11:52:44 CEST 2010

Graeme Geldenhuys schrieb:
> On 18 May 2010 10:12, Florian Klaempfl wrote:
>> - it is one of the basic programming principles: if a result is returned
>> by a subroutine, use a function
> The function might return a boolean (success/fail), or an error code
> etc.. The function result doesn't need to return the new instance
> created by the factory method.

I see, we should change the constructor syntax for you as well ;)

> But I guess the only solution (forced upon me now) is to use some
> magic code like LCL does. An untyped variable (YUCK!!! They are as bad
> as Variants!) and then type cast it inside the implementation of
> CreateForm and use the 'is' operator to find out if the instance
> really is a TfpgWindowBase descendant. A whole much of crap code that
> wasn't needed with FPC 2.4.1. Oh well. :-/

Yes, but imo it doesn't get worse.
As far as I understand CreateForm, before
fpgApplication.CreateForm(TMyForm, NotAMyForm);
was possible as well, so you need to check the parameters anyways.

Maybe (and really only maybe) the proper solution in this case are C++
styled template methods.

More information about the fpc-devel mailing list