[fpc-devel] Parameters must match exactly?
Martin
fpc at mfriebe.de
Mon May 17 23:20:57 CEST 2010
On 17/05/2010 22:10, Marcos Douglas wrote:
> On Mon, May 17, 2010 at 4:24 PM, Florian Klaempfl
> <florian at freepascal.org> wrote:
>
>> ... and one uses normally a function and not a var/out parameter.
>>
> No... If you forget to put a variable to receive the function result
> (a object created), a memory leak will happen.
> The "out" parameter requires a variable.
>
I am sorry, am I missing the point? The idea is to have a factoruy method
procedure xxx(var SomeFoo: TFooType): Boolean;
so it will return in SomeFoo a newly created object?
As far as I can see that still works very well.
The type *declaration* of the var param and the variable passed in must
match 100%; so what
var
FooToBeCreated: TFooType;
begin
if xxx(FooToBeCreated) then ...;
that should to nice.
FooToBeCreated can be assigtne a value of TFooType, or any descendant of
TFooType; which is exactly what a factory is there fore.
Martin
More information about the fpc-devel
mailing list