Re: [fpc-pascal] Out of scope method?

2017-04-06 Thread Tony Whyman
Ryan, If you want an example of a complete API implemented using reference counted interfaces than you could do worse than look at my Firebird Pascal API (See https://www.mwasoftware.co.uk/fb-pascal-api). It's fully documented and works with both FPC and Delphi. Tony Whyman MWA On

Re: [fpc-pascal] Out of scope method?

2017-04-06 Thread Marcos Douglas B. Santos
On Thu, Apr 6, 2017 at 12:23 PM, Ryan Joseph wrote: >> In fact is the opposite: >> TAction needs to have all methods that IAction have. >> This TAction class in the example is not the same class in RTL. >> >> You shouldn't have so many methods in just one class. >> So,

Re: [fpc-pascal] Out of scope method?

2017-04-06 Thread Ryan Joseph
> On Apr 6, 2017, at 10:01 PM, Marcos Douglas B. Santos > wrote: > > In fact is the opposite: > TAction needs to have all methods that IAction have. > This TAction class in the example is not the same class in RTL. > > You shouldn't have so many methods in just one class. >

Re: [fpc-pascal] Out of scope method?

2017-04-06 Thread Marcos Douglas B. Santos
On Thu, Apr 6, 2017 at 11:48 AM, Ryan Joseph wrote: > >> On Apr 6, 2017, at 9:42 PM, Marcos Douglas B. Santos >> wrote: >> >> Lose type checking? >> Of course not. You still use the same language, interfaces, classes... >> >> Don't confuse "New, the

Re: [fpc-pascal] Out of scope method?

2017-04-06 Thread Ryan Joseph
> On Apr 6, 2017, at 9:42 PM, Marcos Douglas B. Santos wrote: > > Lose type checking? > Of course not. You still use the same language, interfaces, classes... > > Don't confuse "New, the function" with "New, a method in a class". I should say that you need to have a matching

Re: [fpc-pascal] Out of scope method?

2017-04-06 Thread Marcos Douglas B. Santos
On Thu, Apr 6, 2017 at 11:01 AM, Ryan Joseph wrote: > > > > On Apr 6, 2017, at 8:54 PM, Marcos Douglas B. Santos > > wrote: > > > > Pretty clear, right? > > > > Because this "problem" I have a "pattern" that I called "New Method". > > > > You can

Re: [fpc-pascal] Out of scope method?

2017-04-06 Thread Ryan Joseph
> On Apr 6, 2017, at 8:54 PM, Marcos Douglas B. Santos wrote: > > Pretty clear, right? > > Because this "problem" I have a "pattern" that I called "New Method". > > You can see how it works in my article: > (you need to translate from Portuguese) >

Re: [fpc-pascal] Out of scope method?

2017-04-06 Thread Marcos Douglas B. Santos
On Thu, Apr 6, 2017 at 10:41 AM, Ryan Joseph wrote: > >> On Apr 6, 2017, at 8:13 PM, Marcos Douglas B. Santos >> wrote: >> >> I can guarantee that reference counting is not a bad idea. >> I have been using this for years and in my own code I do not

Re: [fpc-pascal] Out of scope method?

2017-04-06 Thread Ryan Joseph
> On Apr 6, 2017, at 8:13 PM, Marcos Douglas B. Santos wrote: > > I can guarantee that reference counting is not a bad idea. > I have been using this for years and in my own code I do not use Free > method anymore (only if I need to use some classes of RTL or some 3rd >

Re: [fpc-pascal] Out of scope method?

2017-04-06 Thread Ryan Joseph
> On Apr 6, 2017, at 7:45 PM, Sven Barth via fpc-pascal > wrote: > > Arrays are reference counted, class instances are not. So if the compiler > would blindly free the instance after it goes out of scope if might free > something that another code part still

Re: [fpc-pascal] Out of scope method?

2017-04-06 Thread Marcos Douglas B. Santos
Hi Ryan, On Thu, Apr 6, 2017 at 7:28 AM, Ryan Joseph wrote: > Hmm, that sounds like a hack. Is the verdict this is generally a bad idea? I > was > just curious about it and it seems like a reasonable feature a language may > have. I can guarantee that reference

Re: [fpc-pascal] Out of scope method?

2017-04-06 Thread Sven Barth via fpc-pascal
Am 06.04.2017 11:58 schrieb "Ryan Joseph" : > > > > On Apr 6, 2017, at 4:26 PM, Sven Barth via fpc-pascal < fpc-pascal@lists.freepascal.org> wrote: > > > > It's a difficult topic, cause in Object Pascal class instances are always on the heap while in C++ they might be

Re: [fpc-pascal] Out of scope method?

2017-04-06 Thread Marco van de Voort
In our previous episode, Ryan Joseph said: > > > > And reference counting as garbage collection method has been discussed to > > dead on various maillists and forums. Both Delphi and Lazarus/FPC. > > Hmm, that sounds like a hack. Is the verdict this is generally a bad idea? There is a reason

Re: [fpc-pascal] Out of scope method?

2017-04-06 Thread Ryan Joseph
> On Apr 6, 2017, at 5:09 PM, Marco van de Voort wrote: > > No, since you don't declare an interface variable, but a class variable. > > There are a zillion Delphi faqs about this, but the crux is to use > > var > scope:IInterface; > > And reference counting as garbage

Re: [fpc-pascal] Out of scope method?

2017-04-06 Thread Marco van de Voort
In our previous episode, Ryan Joseph said: > > See http://freepascal.org/docs-html/current/ref/refse48.html#x101-1230007.7 > > for an example. > > > > See also http://wiki.freepascal.org/How_To_Use_Interfaces > > "All COM interfaces use reference counting. This means that whenever an >

Re: [fpc-pascal] Out of scope method?

2017-04-06 Thread Ryan Joseph
> On Apr 6, 2017, at 4:26 PM, Sven Barth via fpc-pascal > wrote: > > It's a difficult topic, cause in Object Pascal class instances are always on > the heap while in C++ they might be on the stack as well. Thus a C++ compiler > will insert calls to the

Re: [fpc-pascal] Out of scope method?

2017-04-06 Thread Ryan Joseph
> On Apr 6, 2017, at 4:30 PM, Tony Whyman > wrote: > > See http://freepascal.org/docs-html/current/ref/refse48.html#x101-1230007.7 > for an example. > > See also http://wiki.freepascal.org/How_To_Use_Interfaces "All COM interfaces use reference counting. This

Re: [fpc-pascal] Out of scope method?

2017-04-06 Thread Tony Whyman
See http://freepascal.org/docs-html/current/ref/refse48.html#x101-1230007.7 for an example. See also http://wiki.freepascal.org/How_To_Use_Interfaces On 06/04/17 10:08, Ryan Joseph wrote: On Apr 6, 2017, at 3:45 PM, Tony Whyman wrote: Isn't this what a COM

Re: [fpc-pascal] Out of scope method?

2017-04-06 Thread Sven Barth via fpc-pascal
Am 06.04.2017 10:32 schrieb "Ryan Joseph" : > > Does it exist now or has it ever been discussed that a method in TObject could be called when an instance of an object goes out of scope? It’s common to clean up objects in a function body after the function exits and

Re: [fpc-pascal] Out of scope method?

2017-04-06 Thread Ryan Joseph
> On Apr 6, 2017, at 3:45 PM, Tony Whyman > wrote: > > Isn't this what a COM Interface does - or at least a descendent of > TInterfacedObject? > > Tony Whyman No idea. Examples? Regards, Ryan Joseph ___

Re: [fpc-pascal] Out of scope method?

2017-04-06 Thread Tony Whyman
Isn't this what a COM Interface does - or at least a descendent of TInterfacedObject? Tony Whyman MWA On 06/04/17 09:00, Ryan Joseph wrote: Does it exist now or has it ever been discussed that a method in TObject could be called when an instance of an object goes out of scope? It’s common