August
2004-10-04 01:46:13 UTC
Hi folks,
For the case of efficiency, Wirth himself among others encourages the use of
reference parameters with arrays and records even if they are not being
modified. I have never studied the subject of compilers in great detail, but
shouldn't an optimizing compiler be able to deal with this.
As the actual parameter in these cases is either a variable or a string
literal (which have an address), the compiler could translate the formal
parameter into a reference parameter if it can conclude that the (value)
parameter is never modified. Using reference parameters for intended
efficiency would instead have negative effects as the compiler, without
access to the procedure implementation, must assume that the procedure may
modify these paramterers. This means that it will not be able to perform the
optimization described.
Any comments?
-- August
For the case of efficiency, Wirth himself among others encourages the use of
reference parameters with arrays and records even if they are not being
modified. I have never studied the subject of compilers in great detail, but
shouldn't an optimizing compiler be able to deal with this.
As the actual parameter in these cases is either a variable or a string
literal (which have an address), the compiler could translate the formal
parameter into a reference parameter if it can conclude that the (value)
parameter is never modified. Using reference parameters for intended
efficiency would instead have negative effects as the compiler, without
access to the procedure implementation, must assume that the procedure may
modify these paramterers. This means that it will not be able to perform the
optimization described.
Any comments?
-- August