A constant (const) parameter is like a local constant or read-only variable. Constant parameters are similar to value parameters, except that you can't assign a value to a constant parameter within the body of a procedure or function, nor can you pass one as a var parameter to another routine. (But when you pass an object reference as a constant parameter, you can still modify the object's properties.)
Using const allows the compiler to optimize code for structured- and string-type parameters. It also provides a safeguard against unintentionally passing a parameter by reference to another routine.
Here, for example, is the header for the CompareStr function in the SysUtils unit:
function CompareStr(const S1, S2: string): Integer;
Because S1 and S2 are not modified in the body of CompareStr, they can be declared as constant parameters.
//-----------------------------------------
procedure Pr(var y);
В этом примере параметр y объявлены нетипизированным.
В тексте процедуры или функции для нетипизированного параметра должна применяться операция явного приведения типов, определяющая тип этого параметра. Например:
real(Y) := real(Y)*10;
Реальный тип аргумента должен соответствовать типу, принятому в процедуре, но не обязательно точно. Например, если параметр - массив, то размер массива, определенный в процедуре, может превышать размер аргумента. Если же получается несоответствие типов (например, аргумент - real, а в процедуре он описан как integer), то никаких сообщений об ошибках и никаких исключений генерироваться не будет, но результаты вычислений будут неверными.
__________________
Je venus de nulle part
55.026263 с.ш., 73.397636 в.д.