[fpc-pascal] various ways of passing a class instance as a parameter

2011-11-15 Thread Graeme Geldenhuys
Hi, What exactly is the difference (if any) between the parameter modifier when you pass a class instance to a procedure? In the example below, I can define foo() as follows... procedure foo(AClass: TStringList); or procedure foo(var AClass: TStringList); or procedure foo(const AClass:

Re: [fpc-pascal] various ways of passing a class instance as a parameter

2011-11-15 Thread Alexander Shishkin
15.11.2011 13:33, Graeme Geldenhuys пишет: Hi, What exactly is the difference (if any) between the parameter modifier when you pass a class instance to a procedure? I your example there is no difference, except that var could be ~0.01% slower

Re: [fpc-pascal] various ways of passing a class instance as a parameter

2011-11-15 Thread michael . vancanneyt
On Tue, 15 Nov 2011, Graeme Geldenhuys wrote: Hi, What exactly is the difference (if any) between the parameter modifier when you pass a class instance to a procedure? It behaves exactly the same as if you would pass a typed pointer. Michael.

Re: [fpc-pascal] various ways of passing a class instance as a parameter

2011-11-15 Thread Martin Schreiber
On Tuesday 15 November 2011 10.33:13 Graeme Geldenhuys wrote: Hi, What exactly is the difference (if any) between the parameter modifier when you pass a class instance to a procedure? In the example below, I can define foo() as follows... procedure foo(AClass: TStringList); or Take

Re: [fpc-pascal] various ways of passing a class instance as a parameter

2011-11-15 Thread Graeme Geldenhuys
On 15/11/2011, Martin Schreiber mse0@g. wrote: Thanks Martin. Extending my example by changing the body of foo() too... AClass.Free; AClass := TStringList.Create; AClass.Add('inside foo'); ...reveals a bit more about the differences. procedure foo(const AClass: TStringList);

Re: [fpc-pascal] various ways of passing a class instance as a parameter

2011-11-15 Thread Martin Schreiber
On Tuesday 15 November 2011 11.00:34 Graeme Geldenhuys wrote: procedure foo(const AClass: TStringList); Take a copy of the AClass instance pointer, AClass is readonly. This one confused me a bit. I thought the whole object would be read-only, but in fact it is just the AClass instance