On 17/05/2010 22:10, Marcos Douglas wrote:
On Mon, May 17, 2010 at 4:24 PM, Florian Klaempfl
<flor...@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
_______________________________________________
fpc-devel maillist - fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel