On Sat, 7 Nov 2009 13:44:39 +1000
Alexander Klenin <[email protected]> wrote:

>[...]
> 2) However, there is an obvious room for improvement here:
> not only Inc/Dec, but any procedure accepting var parameter
> should be able to accept writeable property of the same type.

Var parameters must fit exactly for typecasts and pointers.

procedure DoIt(var i: integer);
begin
  DoSome(@i);
end;

This is not possible with a Setter function.


> (especially common example is Include/Exclude for set properties)
> 
> For each property argument, the compiler should create temporary
> variable, set it by reading the property before the function call,
> and set property to the new value
> after the call.
> 
> Inc(MyObj.MyIntProperty);
> =>
> var
>   temp: Integer;
> 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.

I guess this would be possible for compiler functions like inc.

Mattias
 

--
_______________________________________________
Lazarus mailing list
[email protected]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to