Prof A Olowofoyeku (The African Chief) wrote:
On 28 Feb 2005 at 17:38, Frank Heckenbach wrote:
In the GPC interfaces for Mac OS X, we use the external declaration form with a "protected var" because (according to the gc docs) the "const" declaration form doesn't guarantuee that the parameter is passed by reference, which is an ABI requirement.
In general it doesn't. This particular type is currently passed by reference (as `const'), so for a temporary work-around (until GPC has short strings) it may be acceptable.
Is it possible to add a compiler directive or something like that to force the passing of "const" parameters by reference? Another possible option is a new keyword "ByRef" - e.g., procedure foo (ByRef {const} bar : BarType); Now that I've typed it, it looks very silly indeed. But Visual Basic (!) has "ByRef". I doubt that we need a new keyword in GPC. So I would probably still plumb for adding a new compiler directive: - e.g., "{$reference-const-parameters}" or "--reference-const-parameters" at the command line.
I think a compiler directive is too broad here because you usually don't want it for all types (in particular simple types).
As you all know, I don't like adding new keywords either. Reusing existing keywords is a bit better ... `const var Foo: Bar' ...?
Frank