Difference between revisions of "Constref"

From Free Pascal wiki
Jump to navigationJump to search
(Create)
 
Line 1: Line 1:
 
Version 2.6 of Free Pascal added the '''constref''' parameter qualifier. It is like a combination of the [[Var|var]] and [[Const | const]] parameter qualifiers. The argument is passed by reference, but cannot be modified. If you do try and modify the parameter, the compiler will flag it as an error: " Error: Can't assign values to const variable". The [[FPC_New_Features_2.6.0#Constref_parameter_modifier | new feature notes]] for version 2.6 suggest that you should only use this for interfacing with external routines in other languages, where this type of parameter passing is required.
 
Version 2.6 of Free Pascal added the '''constref''' parameter qualifier. It is like a combination of the [[Var|var]] and [[Const | const]] parameter qualifiers. The argument is passed by reference, but cannot be modified. If you do try and modify the parameter, the compiler will flag it as an error: " Error: Can't assign values to const variable". The [[FPC_New_Features_2.6.0#Constref_parameter_modifier | new feature notes]] for version 2.6 suggest that you should only use this for interfacing with external routines in other languages, where this type of parameter passing is required.
  
 +
== See also ==
 +
* [[const]]
 +
** [[var]]
  
 
[[category:Reserved words]]
 
[[category:Reserved words]]

Revision as of 11:44, 24 July 2016

Version 2.6 of Free Pascal added the constref parameter qualifier. It is like a combination of the var and const parameter qualifiers. The argument is passed by reference, but cannot be modified. If you do try and modify the parameter, the compiler will flag it as an error: " Error: Can't assign values to const variable". The new feature notes for version 2.6 suggest that you should only use this for interfacing with external routines in other languages, where this type of parameter passing is required.

See also