Does FPC support garbage collection like Delphi for .NET?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Does FPC support garbage collection like Delphi for .NET?

Song Zhiwei
There are class TTestA and TTestB:

type
  TTestB = class end;
  TTestA = class
    B: TTestB;
    constructor Create(BParam: TTestB);
  end;

constructor TTestA.Create(BParam: TTestB);
begin
  B:= BParam;
 end;

var
  A: TTestA;
begin
  A:= TTestA.Create(TTestB.Create);
  A:= nil; // Now, the instances of TTestA and TTestB created in
           // above line can be freed automatically?
end.

As I known, Delphi for .NET does support garbage collection.
And the above instances can be freed automatically?
How about FPC?


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Does FPC support garbage collection like Delphi for .NET?

Florian Klaempfl
Song Zhiwei wrote:

> There are class TTestA and TTestB:
>
> type
>   TTestB = class end;
>   TTestA = class
>     B: TTestB;
>     constructor Create(BParam: TTestB);
>   end;
>
> constructor TTestA.Create(BParam: TTestB);
> begin
>   B:= BParam;
>  end;
>
> var
>   A: TTestA;
> begin
>   A:= TTestA.Create(TTestB.Create);
>   A:= nil; // Now, the instances of TTestA and TTestB created in
>            // above line can be freed automatically?
> end.
>
> As I known, Delphi for .NET does support garbage collection.
> And the above instances can be freed automatically?
> How about FPC?

No. We don't think that GC fits into the paradigma of pascal because it enables
sloppy and bad programming style.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal