Re: [fpc-pascal] Interface, _AddRef, _Release, etc.

2011-09-16 Thread Graeme Geldenhuys
On 15/09/2011 17:12, Felipe Monteiro de Carvalho wrote: http://wiki.lazarus.freepascal.org/How_To_Use_Interfaces_to_write_less_code Should that example not mention that it will not work with any released FPC version to date? That example will only work with the still to be released 2.6.0 and

Re: [fpc-pascal] Interface, _AddRef, _Release, etc.

2011-09-16 Thread Graeme Geldenhuys
On 15/09/2011 16:54, Marcos Douglas wrote: Well, wrong just because the language is so but not because is ilogical, right? Unless you are well versed with interfaces, I would not go there. Mixing object references and interface references (especially if reference counting is enabled) - you

Re: [fpc-pascal] Interface, _AddRef, _Release, etc.

2011-09-16 Thread Graeme Geldenhuys
You're original problem is exactly why I said mixing class instances and interface instance is looking for trouble. You better know what you are doing. Attached are two examples of your program. One using CORBA interfaces, the other using non-reference counting COM style interface. Both work

Re: [fpc-pascal] Interface, _AddRef, _Release, etc.

2011-09-16 Thread Jonas Maebe
On 16 Sep 2011, at 09:02, Graeme Geldenhuys wrote: Should that example not mention that it will not work with any released FPC version to date? No. That example will only work with the still to be released 2.6.0 and later. Why Because current released FPC versions don't support the

Re: [fpc-pascal] Interface, _AddRef, _Release, etc.

2011-09-16 Thread Marcos Douglas
On Fri, Sep 16, 2011 at 4:02 AM, Graeme Geldenhuys graemeg.li...@gmail.com wrote: On 15/09/2011 17:12, Felipe Monteiro de Carvalho wrote: http://wiki.lazarus.freepascal.org/How_To_Use_Interfaces_to_write_less_code Should that example not mention that it will not work with any released FPC

Re: [fpc-pascal] Interface, _AddRef, _Release, etc.

2011-09-16 Thread Marcos Douglas
On Fri, Sep 16, 2011 at 5:26 AM, Jonas Maebe jonas.ma...@elis.ugent.be wrote: That is incorrect. Several things have been fixed regarding the implements functionality in 2.5.x, but the basics already worked in 2.4.4. The example works fine when compiled with 2.4.4 Exactly (I did not see your

Re: [fpc-pascal] Interface, _AddRef, _Release, etc.

2011-09-16 Thread Marcos Douglas
On Fri, Sep 16, 2011 at 4:46 AM, Graeme Geldenhuys graemeg.li...@gmail.com wrote: You're original problem is exactly why I said mixing class instances and interface instance is looking for trouble. You better know what you are doing. Attached are two examples of your program. One using CORBA

Re: [fpc-pascal] Interface, _AddRef, _Release, etc.

2011-09-15 Thread Zaher Dirkey
On Thu, Sep 15, 2011 at 12:27 PM, Graeme Geldenhuys graemeg.li...@gmail.com wrote: On 14/09/2011 23:17, Marcos Douglas wrote: procedure Run; var f: TFoo; // type is class, not interface o: TObj; begin f := TFoo.Create; This is just wrong. 1 - If i use the class not

Re: [fpc-pascal] Interface, _AddRef, _Release, etc.

2011-09-15 Thread Jonas Maebe
On 14 Sep 2011, at 23:17, Marcos Douglas wrote: BUT, if I create my TFoo without refcount should works, right? Only in some circumstances. These circumstances depend on when the compiler allocates temporary interface instances, and when these are finalized. ... but, does not work. In

Re: [fpc-pascal] Interface, _AddRef, _Release, etc.

2011-09-15 Thread Marcos Douglas
On Thu, Sep 15, 2011 at 6:27 AM, Graeme Geldenhuys graemeg.li...@gmail.com wrote: On 14/09/2011 23:17, Marcos Douglas wrote: procedure Run; var   f: TFoo;  // type is class, not interface   o: TObj; begin   f := TFoo.Create; This is just wrong. Well, wrong just because the language is

Re: [fpc-pascal] Interface, _AddRef, _Release, etc.

2011-09-15 Thread Marcos Douglas
On Thu, Sep 15, 2011 at 9:18 AM, Jonas Maebe jonas.ma...@elis.ugent.be wrote: On 14 Sep 2011, at 23:17, Marcos Douglas wrote: BUT, if I create my TFoo without refcount should works, right? Only in some circumstances. These circumstances depend on when the compiler allocates temporary

Re: [fpc-pascal] Interface, _AddRef, _Release, etc.

2011-09-15 Thread Felipe Monteiro de Carvalho
On Thu, Sep 15, 2011 at 4:54 PM, Marcos Douglas m...@delfire.net wrote:   f := TFoo.Create; This is just wrong. Well, wrong just because the language is so but not because is ilogical, right? I don't understand why it would be wrong. For me it seams correct and similar to this example:

Re: [fpc-pascal] Interface, _AddRef, _Release, etc.

2011-09-15 Thread Marcos Douglas
On Thu, Sep 15, 2011 at 12:12 PM, Felipe Monteiro de Carvalho felipemonteiro.carva...@gmail.com wrote: On Thu, Sep 15, 2011 at 4:54 PM, Marcos Douglas m...@delfire.net wrote:   f := TFoo.Create; This is just wrong. Well, wrong just because the language is so but not because is

Re: [fpc-pascal] Interface, _AddRef, _Release, etc.

2011-09-15 Thread Marcos Douglas
On Thu, Sep 15, 2011 at 12:12 PM, Felipe Monteiro de Carvalho felipemonteiro.carva...@gmail.com wrote: I don't understand why it would be wrong. For me it seams correct and similar to this example: http://wiki.lazarus.freepascal.org/How_To_Use_Interfaces_to_write_less_code I'd like to use the

Re: [fpc-pascal] Interface, _AddRef, _Release, etc.

2011-09-15 Thread Marcos Douglas
On Thu, Sep 15, 2011 at 4:45 PM, Marcos Douglas m...@delfire.net wrote: Yeah, you're right... I didn't see this link.  =) But see it one more time: the R instance of TRealClass is not released... saw? I didn't test but I think if R was released will occur an AV. As I said, if we use