Protected parameters (Was: Some bug reports - and success report)_(re)

Tue, 4 Mar 1997 17:17:30 GMT



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
-- 
Frank Heckenbach, Erlangen, Germany
heckenb@mi.uni-erlangen.de
Turbo Pascal:   http://www.mi.uni-erlangen.de/~heckenb/programs.htm
Internet links: http://www.mi.uni-erlangen.de/~heckenb/links.htm


Frank Heckenbach (heckenb@mi.uni-erlangen.de)

HTML conversion by Lluís de Yzaguirre i Maura
Institut de Lingüística Aplicada - Universitat "Pompeu Fabra"
e-mail: de_yza@upf.es