Re: [fpc-devel] interface vs optimizer

2006-01-21 Thread Florian Klaempfl

mariano podesta wrote:

ok, but is this a correct behavior?


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 think it would be best to optimize with a compiler switch or to give a 
switch to turn it off.

i have big porting problems :(


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

___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re: [fpc-devel] interface vs optimizer

2006-01-21 Thread mariano podesta
Yes. Why should the interface life longer? There isn't any owneranymore? 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 listend;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 byaccident?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


[fpc-devel] interface vs optimizer

2006-01-20 Thread mariano podesta
hi people,there is a problem with functions returning interfaces:if nobody stores the result, the object decrements one reference despite turn off optimizations.sample:function getobj: IUnknown;
begin Result := TInterfacedObject.Create;end;procedure test;begin getobj; // here result of getobj has died :(end;es there a solution or workaround?thanks,marianop
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re: [fpc-devel] interface vs optimizer

2006-01-20 Thread Alexey Barkovoy

This is by design.


- Original Message - 
From: mariano podesta

To: fpc-devel@lists.freepascal.org
Sent: Saturday, January 21, 2006 1:56 AM
Subject: [fpc-devel] interface vs optimizer


hi people,
there is a problem with functions returning interfaces:
if nobody stores the result, the object decrements one reference despite turn 
off optimizations.


sample:

function getobj: IUnknown;
begin
 Result := TInterfacedObject.Create;
end;

procedure test;
begin
 getobj;
 // here result of getobj has died :(
end;

es there a solution or workaround?

thanks,
marianop




___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel 


___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re: [fpc-devel] interface vs optimizer

2006-01-20 Thread mariano podesta
ok, but is this a correct behavior?i think it would be best to optimize with a compiler switch or to give a switch to turn it off.i have big porting problems :(
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel