If a variable is passed as a constant does it get passed by reference?

349 Views Asked by At

If I pass a variable as a constant does it automatically get passed by reference?

procedure foo(const x : integer)

I can already pass a variable by reference like this:

procedure foo(var y : integer);

Ideally I'd want something like the code below:

procedure foo(const var z : integer)
1

There are 1 best solutions below

1
On BEST ANSWER

const does not guarantee that the value is actually passed by reference.

Free Pascal supports

procedure foo(constref z : integer);

for this purpose: z is always passed by reference in this case. I'am not aware of something similiar in other pascal compiler.