Ver Mensaje Individual
  #11  
Antiguo 19-08-2008
Avatar de roman
roman roman is offline
Moderador
 
Registrado: may 2003
Ubicación: Ciudad de México
Posts: 20.269
Reputación: 10
roman Es un diamante en brutoroman Es un diamante en brutoroman Es un diamante en bruto
Y bueno, al parecer las formas realmente equivalentes son estas:

Forma anidada:

Código Delphi [-]
var
  A: TObjetoA;
  B: TObjetoB;

begin
  A := TObjetoA.Create;

  try
    B := TObjetoB.Create;

    try

      { algo de código }

    finally
      B.Free;
    end;
  finally
    A.Free;
  end;
end;

Forma compacta:

Código Delphi [-]
var
  A: TObjetoA;
  B: TObjetoB;

begin
  A := nil;
  B := nil;

  try
    A := TObjetoA.Create;
    B := TObjetoB.Create;

    { algo de código }

  finally
    A.Free;
    B.Free;
  end;
end;

Y yo estaba equivocado. Puesto así, el compilador no genera ningún warning.

// Saludos
Responder Con Cita