Peter N Lewis wrote:
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?
The former. I notice that this case currently is "broken" with `const var' as well, so thanks for pointing me to this issue. I'll try to fix both cases before the next release.
BTW, unless you require the parameter to be limited to 1000 chars, you could simply declare it as `String'. This case works in GPC and it's usually more general (that's why I use it almost always, and therefore hadn't noticed the bug before).
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?
Yes, Waldek sent me a patch ready for integration. I'll have to finish some of my own changes. But first I'd like to re-install the web server, as putting a new release on a fully working server seems preferable ... ;-) I'll be off for a few days, so probably about 2 weeks ...
Frank