Talk:Dynamic array

From Lazarus wiki
Jump to navigationJump to search

I was a little bit confused about the sentence "To init such an invalid pointer you have to use FillChar(MyVariable,sizeof(MyVariable), #0)." This might be misleading, as this fills the pointer to MyVariable with the size of this pointer with zeros, not the array itself, as far as I understand. This might be different to static arrays (didn't prove that). Logically, the sentence is right. But it's anyway confusing, because the instruction does not do, what it seems to do in human language: FillChar doesn't fill My(Array)Variable, and SizeOf doesn't return the size of MyVariable...

It took me some time to understand this. Then it's not very hard to find out, how to initialize the array itself:

 FillChar(MyVariable[0], Length(MyVariable) * SizeOf(TheArrayType), #0);

So the problem is mainly the terminology, which puts you on the wrong trace. Perhaps this difference between initializing the array itself and the reference to the array should be emphasized? Or did I misunderstand something there?

change under 'concept'

It said that it was not possible 'to change the first element being specified by an index of 1'. This seemed wrong to me, although, this being my first edit here, I won't be surprised if I'm the one who's wrong. ;) Anyway, I changed it to read 'to change the first element from being specified by an index of 0', because I'm fairly certain that is true. Eaglizard (talk) 16:55, 10 March 2020 (CET)

"to change the first element form being specified by an index other than 0" sounds better to me, but better ask someone who speaks english natively (I'm Dutch). --Bart (talk) 22:31, 10 March 2020 (CET)

Hell, then I got all excited and went and cleaned up the whole article. I might even do this again, on occasion, if nobody complains too much about it. Eaglizard (talk) 17:17, 10 March 2020 (CET)