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.
_______________________________________________ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel