Peter N Lewis wrote:
As far as I can see, the only purpose in the "const" keyword in this case is to get it passed by reference, but not allowed to be modified so you can pass things like strings and records without the cost of copying or the fear of changing your source. For simple types you would just pass by value.
I have not checked the rules gpc uses. But speaking about purpose, consider:
type alpha : array[1..8] of char;
On 64-bit machine passing `alpha' by value (in a register) is likely to more efficient then passing reference. On 32-bit machine reference is probably more efficient. On machines with vector registers it may pay off to pass larger arrays in registers. So one meaning is "the value will not change, use most efficient method to pass parameters".
Also, `var' (even protected) parameter has special semantics: the value _can_ change due to direct assignments to global variables (or due to routine calls). In many cases the compiler has to read values directly from memory, even if previously read value is still available in registers. Indirect modifications of `const' may be considered as an error, since the programmer can not rely on parameters being modified (or not modified). So, in principle `const' parameters allow better optimization. Of course, once we document that certain `const' parameters are always passed by reference programmers may try dirty tricks...
Concerning `Str255': it would take rather strange machine (high bandwidth, high latency distributed machine ???) for such type to be passed by value. For such machine sticking to Apple ABI seem pointless...