I feel like this was addressed but I couldn't find any references. The program 
below prints the following:

  Initialize
  Create
  Finalize
  Finalize

Why is Finalize called twice? I thought those were supposed to be called in 
pairs with initialize?

==================

{$mode objfpc}
{$modeswitch advancedrecords}

program test;

type
  TManagedObject = record
    class function Create: TManagedObject; static;
    class operator Finalize(var self: TManagedObject); inline;
    class operator Initialize(var self: TManagedObject); inline;
  end;

class function TManagedObject.Create: TManagedObject;
begin
  writeln('Create');
end;

class operator TManagedObject.Finalize(var self: TManagedObject);
begin
  writeln('Finalize');
end;

class operator TManagedObject.Initialize(var self: TManagedObject);
begin
  writeln('Initialize');
end;

begin
  TManagedObject.Create;
end.

Regards,
        Ryan Joseph

_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to