On 19 Jan 2010, at 14:39, Roland Turcan wrote:

<<< 19.01.2010 13:10 - Jonas Maebe "jonas.ma...@elis.ugent.be" >>>

JM> Oops, only now I see he was trying to index a pointer like an array. JM> And even in FPC I would very strongly recommend against typecasting a JM> dynamic array to a pointer and then performing operations using this JM> pointer. Dynamic arrays are opaque structures and trying to directly
JM> access the underlying data should never be done.

But this ways is already used in LCL/FPC source as well.

I don't know about the LCL, but I guess in the FPC sources the only place where this is done is inside the RTL helpers that are used to manage the dynamic arrays. These by definition depend on the internal layout of the dynamic array and will be updated if something would change about dynamic arrays.

I also don't see any advantage to using a pointer instead of a dynamic array directly. It will not be faster in any way, since there are no uniqueness checks for dynamic arrays. In fact, it will probably be slower, since you now have two variables in use: one to hold a reference to the dynamic array, and one for the extra pointer.


Jonas
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to