On Sat, 5 Feb 2011 09:24:44 +0100 (CET),
michael.vancann...@wisa.be wrote:

>
>No. Someone misunderstands the concept of dynamic array here.
>
>A "dynamic array" is a pointer to an array in memory.
>So when passing a dynamic array to a function, 
>you are, in fact, passing a pointer.
>
>> So is there a difference here between Delphi7 and FPC?
>
>No.
>

So in effect it means that all of these calls are exactly the same:

FillArr(const Arr: TByteArr)
FillArr(var Arr: TByteArr)
FillArr(Arr: TByteArr)

At least as long as the FillArr function does not attempt to change
the ponter itself like this:

Arr := SomeOtherArr;

In which case I guess that the only version that will carry this back
to the caller is the var version?

But that is not what I am doing at all, so I can stick with a simple:

FillArr(Arr: TByteArr)

and be sure that I will not get back a different array, but instead
get my array filled as requested...


-- 
Bo Berglund
Developer in Sweden

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

Reply via email to