Einzelnen Beitrag anzeigen

DieDolly

Registriert seit: 22. Jun 2018
2.175 Beiträge
 
#4

AW: Procedur verstehen

  Alt 2. Jul 2019, 19:45
Nimm das [ref] einfach weg. Ich kann mir nicht vorstellen, dass das dahin gehört.

https://pascal.today/2016/08/17/cons...-vs-non-const/
Zitat:
Const

The const parameters are almost the same as standard parameters, but have some differences. It is not allowed to set the value to the const parameter inside of the function/procedure either pass it as a var/out parameter to other routines. The const parameters are passed by value (simple types) or by reference (string, fixed array, dynamic arrays and records. However this depends on the size of the parameter. If the size of the parameter is bigger than a certain amount of bytes then it is passed by reference instead) but without copy on write – remember, those are marked read-only and we cannot assign values to them or pass them to var parameters of other routines. You can specify [Ref] before the parameter to force the compiler to pass the value by reference – so it will be the same as var parameter except that the routine cannot modify the value directly via assignment. But be warned that const [Ref] parameters cannot be captured by the anonymous methods (lambdas) – as it is with “Result” in functions.
  Mit Zitat antworten Zitat