[fpc-devel] interface vs optimizer

mariano podesta antiriad at gmail.com
Sat Jan 21 17:12:51 CET 2006


>
> Yes. Why should the interface life longer? There isn't any owner
> anymore? If you need a longer life time, you need to assign the
> interface to something.


i have many structures like this (yes, in delphi):

function TXList.Lock: ILock;
begin
  result := TLock.Create(self);
end;

procedure dostuff;
begin
  list.Lock;
  // use the locked list
  // when ILock is out of scope, unlocks the list
end;

i know the obvious solution is to assign it:

procedure dostuff;
var
  l: ILock;
begin
  l := list.Lock; // assign it
  // use the locked list
  // when ILock is out of scope, unlocks the list
end;

but it is a lot of work (it is a big project) and my pals are not so happy
):-\

Porting from what? Delphi? Are you sure that it didn't on Delphi by
> accident?


i really don't know if it was accident, but we found it useful.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20060121/c70051cc/attachment.html>


More information about the fpc-devel mailing list