[Lazarus] Passing properties as var paramatars (was: Delphi editor clone)

Marco van de Voort marcov at stack.nl
Sat Nov 7 17:50:56 CET 2009


On Sat, Nov 07, 2009 at 01:44:39PM +1000, Alexander Klenin wrote:
> 1) The change was correct in the sense that all properies should be treated
> begin
>   temp := MyObj.MyIntProperty;
>   Inc(temp);
>   MyObj.MyIntProperty := temp;
> end;
> 
> Of course, if the compiler determines that the property is an alias for a field,
> it is free to pass the field directly -- but this is only an optimization.

This is not orthogonal. VAR parameters are generally updated
instantaniously. By delaying the update over a temp variable you break
another aspect of the VAR parameter.

IMHO such kludges only lead to more kludges.




More information about the Lazarus mailing list