At 11:49 +0200 26/7/05, Emil Jerabek wrote:
On Tue, Jul 26, 2005 at 05:26:58PM +0800, Peter N Lewis wrote:
It seems that const parameters of string types are passed by value, eg:
Const parameters may be passed by value or by reference at compiler's discretion. Use protected var to guarantee pass by reference.
I understand that, I just would expect gpc's discretion on how to pass a 1000 byte parameter would be by reference...
I am just in the process of converting fake long strings (record containing length and 2502 characters) used through my code to String(2502). The code after the conversion is much cleaner, and all the routines that are duplicated to handle either String or LongStringRecord can be reconciled. But if const s: String(2502) is going to take up 2502+ bytes on the stack and require a copy for each parameter, I'm going to have to consider either reverting this change or switching to "const var" everywhere. "protected var" is not very good for strings because you cannot then pass a constant string to it.
So is this considered a bug likely to be fixed in the near future, or is this considered a feature likely to be permanent?
I can convert all my use of "const" to "const var" when that support is released, so I guess that will resolve my problem, but it still seems wrong to me that the compiler would choose to pass strings by value...? Is there any compelling reason for const String() being passed by value?
Speaking of "const var", do we have an ETA for a version of the compiler with that support? Possible a new release with Waldek's changes and that support?
Thanks, Peter.