[Lazarus] Passing properties as var paramatars (was: Delphi editor clone)
Martin
lazarus at mfriebe.de
Sat Nov 7 15:22:59 CET 2009
Alexander Klenin wrote:
> On Sat, Nov 7, 2009 at 14:15, Martin <lazarus at mfriebe.de> wrote:
>
>
>> The answer was that properties are meant to change the value on the object
>> immediately. Also a property setter can raise an exception, or additional
>> actions can take place or the value can be substituted....
>> All this wouldn't happen with a temp variable (or at best deferred).
>> Therefore the behaviour would not be according to the rules of properties
>>
>
> I thought about that too. There are few counter-arguments here:
>
> Strictly speaking, properties are not *meant* to change anything
> neither immediately nor
>
As I said it is not my argument, you better take it to the fpc list.
The one thing I may not have repeated clear enough: "expected to change"
Of course the setter is expected to change (at least a member variable).
So if your functions/procedure does
MyProc(var SomeValueFromProertyasTempVar: integer);
begin
SomeValueFromProertyasTemp := 1;
Foo();
end
and Foo reads the property in question, then Foo sees the old value,
even so it is expected to have changed already.
More information about the Lazarus
mailing list