Peter Gerwinski wrote:
According to Frank Heckenbach:
Just wondering - what's the difference between "Const" and "Protected" parameters? Are they only handled differently internally in the compiler, or is there any semantic difference?
`Protected' is a "modifier" which can be used with or without `Var' in formal parameters. `Const' parameters are the same as `protected Var' parameters
Does that mean that protected (not protected var) parameters are passed by value? Especially in the case of large structures, can this be inefficient, taking up stack space and consuming time to copy the arguments?
Since protected parameters are read-only anyway, actually I see no need to distinguish between passing them by value or by reference. Of course, it would be best if the compiler could automatically choose the more efficient way of passing (i.e. small structures by value, and large ones by reference), no matter if declared as "protected", "protected var" or "const". Or does the standard prescribe something different?
Also, defining "Const" as "protected Var" is not completely compatible to BP, since in BP you can pass a calculated expression, not only an "lvalue" as a const parameter.
But of course, these are no urgent issues, as long as one form of protected/const parameters works at all... :-)
Frank