2010/4/30 spir ☣ <denis.s...@gmail.com>:
> Hello,
>
> I wrote a little simulation prog to try and understand better the semantics 
> of var parameters (see below code and output).
>
> It seems they behave like if passed via pointers, but also locally _operated_ 
> via pointers. Meaning there is in ChangeVar no real local variable n (on the 
> stack). But instead Pascal silently behaves like if using p^ for both getting 
> and setting the variable ('s value) "on-place". This is illustrated by the 
> difference of result between the simulating funcs changePtrVar & 
> changePtrDirect.
>
> Is this interpretation more or less correct?
> How are var parameters actually implemented?
>

Yes, var parameters are passed by reference (pointer). See here
Variable Parameters:
http://www.freepascal.org/docs-html/ref/refse59.html.

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

Reply via email to