Re: [fpc-pascal] Why use pointers to arrays?

2009-10-12 Thread Tomas Hajny
On 11 Oct 09, at 10:38, Graeme Geldenhuys wrote: Hi, . . > Anyway to get to my questions, and using the code snippets shown > below. This code is all based on the code I am porting from > SpeedPascal. So maybe some strange usage is simply due to the age of > SpeedPascal etc.. > > > --

Re: [fpc-pascal] Why use pointers to arrays?

2009-10-12 Thread Vinzent Höfler
Andrew Brunner : > On Sun, Oct 11, 2009 at 5:25 PM, "Vinzent Höfler" > > Read up on forward declarations. The technique of declaring a typed > pointer to any data structure in FPC and Delphi was that you can use > it in fields and methods of objects and data structures w/o having to > actually ha

Re: [fpc-pascal] Why use pointers to arrays?

2009-10-12 Thread Henry Vermaak
2009/10/12 Andrew Brunner : >>>  pS[2] <<< > > Any idea what the compiler option is under Lazarus (that's what I use > exclusively)? > > I get a compiler error when I don't use the ^ operator. It only works with {$mode delphi} and lazarus uses {$mode objfpc}, i think. _

Re: [fpc-pascal] Why use pointers to arrays?

2009-10-12 Thread Andrew Brunner
On Mon, Oct 12, 2009 at 12:43 PM, Marc Weustink wrote: > Graeme Geldenhuys wrote: >> >> On 11/10/2009, Andrew Brunner wrote: >>> >>>  FPC forces the ^ operator while accessing structures as pointers. >>>  Delphi didn't force it and I even suspect that memory leaks can result >>>  in NOT using the

Re: [fpc-pascal] Why use pointers to arrays?

2009-10-12 Thread Marc Weustink
Graeme Geldenhuys wrote: On 11/10/2009, Andrew Brunner wrote: FPC forces the ^ operator while accessing structures as pointers. Delphi didn't force it and I even suspect that memory leaks can result in NOT using the ^ to denote the reference to the pointer rather than the pointer itself.

Re: [fpc-pascal] Why use pointers to arrays?

2009-10-12 Thread Andrew Brunner
On Sun, Oct 11, 2009 at 5:25 PM, "Vinzent Höfler" wrote: > Andrew Brunner : > >> 1st benefit: >> >> declaring methods associated with classes before TIntArray needs to be >> defined or declared. >>   eg. procedure DoSomething(Var Data:TIntArray); vs (DataP:PIntArray); > > Huh? Is there any differe

Re: [fpc-pascal] Why use pointers to arrays?

2009-10-11 Thread Vinzent Höfler
Andrew Brunner : > 1st benefit: > > declaring methods associated with classes before TIntArray needs to be > defined or declared. > eg. procedure DoSomething(Var Data:TIntArray); vs (DataP:PIntArray); Huh? Is there any difference other than the second one can take a NIL value? > Lastly, passi

Re: [fpc-pascal] Why use pointers to arrays?

2009-10-11 Thread Graeme Geldenhuys
On 11/10/2009, Andrew Brunner wrote: > FPC forces the ^ operator while accessing structures as pointers. > Delphi didn't force it and I even suspect that memory leaks can result > in NOT using the ^ to denote the reference to the pointer rather than > the pointer itself. This was just discuss

Re: [fpc-pascal] Why use pointers to arrays?

2009-10-11 Thread Andrew Brunner
In general I use pointers to data structures and especially when they are arrays. Take the following PIntArray: ^TIntArray; TIntArray:Array of Integer; 1st benefit: declaring methods associated with classes before TIntArray needs to be defined or declared. eg. procedure DoSomething(Var Data

Re: [fpc-pascal] Why use pointers to arrays?

2009-10-11 Thread Florian Klaempfl
Graeme Geldenhuys schrieb: > > > 1) Why would you use a pointer to an array and not simply a variable > what IS the array? In the program I am porting the following field > variable is defined. > > FLines: ^TLinesArray; > > Why couldn't I simply say: > > FLines: TLinesArray; Because thi

[fpc-pascal] Why use pointers to arrays?

2009-10-11 Thread Graeme Geldenhuys
Hi, The other "arrays" discussion got me thinking, and after working so long with only desktop type applications that talk to database API's, I long some knowledge of the lower lever Pascal features that was so often used in Turbo Pascal days. Anyway, I'm port an application that was written for