If I need to declare function ABC.
The function uese the arguments "By Value".
For example:
function ABC(x,y:real):real;
Begin
result:=x*y;
End;
How is the advantage to put "const" in front of the arguments like this? :
function ABC(const x, y:real):real;
"A function or procedure parameter may be declared const. Any assignment to a const parameter within a procedure or function and the compiler will flag it as an error: "Can't assign values to const variable". Declaring a parameter as const allows the compiler the possibility to do optimizations it couldn't do otherwise, such as passing by reference while retaining the semantics of passing by value. A const parameter cannot be passed to another function or procedure that requires a variable parameter."
http://wiki.freepascal.org/Const"Specifying a parameter as Constant is giving the compiler a hint that the contents of the parameter will not be changed by the called routine. This allows the compiler to perform optimizations which it could not do otherwise, and also to perform certain checks on the code inside the routine: namely, it can forbid assignments to the parameter. Furthermore a const parameter cannot be passed on to another function that requires a variable parameter: the compiler can check this as well. The main use for this is reducing the stack size, hence improving performance, and still retaining the semantics of passing by value...
Remark: Note that specifying const is a contract between the programmer and the compiler. It is the programmer who tells the compiler that the contents of the const parameter will not be changed when the routine is executed, it is not the compiler who tells the programmer that the parameter will not be changed."
https://www.freepascal.org/docs-html/ref/refsu67.html#x179-20100014.4.4"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."
https://stackoverflow.com/questions/25575718/if-a-variable-is-passed-as-a-constant-does-it-get-passed-by-reference