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

Hans-Peter Diettrich DrDiettrich1 at aol.com
Sun Nov 8 03:41:39 CET 2009


Alexander Klenin schrieb:

>>> Using temporary variables, there will be one call to each.
>> Where would you place such temporary variables, in your sample code? Into an
>> invisible layer between the caller and MyInc2?
> 
> Eh... on the stack, as usual. I am not sure what do you mean by
> "invisible layer".

The var parameter already resides on the stack, when the procedure is 
invoked. Given that a var parameter is represented by a memory address, 
what should that address point to?


>> [1] A quick comparison with Delphi 7 revealed:
>>
>> Delphi notices that a property cannot be passed as a var parameter.
>>
>> Delphi also denies Inc(obj.P), so that I have to adjust my opinion about the
>> cleverness of Inc() :-(
>> [What does not influence my opinion about the *expected* behaviour of Inc()
>> :-]
> 
> Yes, passing property as var parameter. if implemented, would be a
> FPC-only extension.

I'm pretty sure that such a feature will never come. It would be easier 
to implement macros with arguments, or generics, that allow for similar 
comfort in a more transparent way.

DoDi





More information about the Lazarus mailing list