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

Hans-Peter Diettrich DrDiettrich1 at aol.com
Sat Nov 7 12:51:16 CET 2009


Paul Ishenin schrieb:
> Alexander Klenin wrote:
>> Inc(MyObj.MyIntProperty);
>> =>
>> var
>>   temp: Integer;
>> begin
>>   temp := MyObj.MyIntProperty;
>>   Inc(temp);
>>   MyObj.MyIntProperty := temp;
>> end;
>>   
> Property does not need to have a reader.

A compiler magic can check for both read and write access to a property.

The above code can be reduced to what now has to be written in explicit 
source code:

   MyObj.MyIntproperty := MyObj.MyIntproperty + delta;

In this case the compiler would have issued a warning, when the property 
was read-only or write-only. Nothing changed by the new property handling.

DoDi





More information about the Lazarus mailing list