[fpc-pascal] about dynamic array

José Mejuto joshyfun at gmail.com
Thu May 6 21:12:18 CEST 2010


Hello FPC-Pascal,

Thursday, May 6, 2010, 8:58:33 PM, you wrote:

>> faster in fact. If the user plans to use a record (which is my
>> suspect) with TList he must "new" and "dispose" the elements and he
>> will end up with a dyn array of pointers after all, which is a TList.
FK> A dyn. array of records requires no new/dispose as well as no type casts
FK> as TList does.

OK, I see :) Do you remember how this veryyyy long thread starts ?

A: array of MyArray;
SetLength(A,x);
A[0]:=MyArrayElement;
Move(A,B,sizeof..);

Entering the doom again... Next question could be why:

p1: TObject;
p2: TObject;
p1:=TObject.Create();
p2:=p1;
P1.free;
p1:=nil;

Why I get an AV if accesing p2 ? Because the object has been freed...
So why is not p2 = nil as p1 ?

This kind of messages will end up or in a master class of pointers for
dummies or a lot of developers dropping the list for days.

I had proposed the "solution" that I think is easy to understand what
happends behind the scenes or maybe I wrongly choose the moment of hit
reply :(

-- 
Best regards,
 José




More information about the fpc-pascal mailing list