[fpc-pascal] += property bug?
Sven Barth
pascaldragon at googlemail.com
Thu Aug 15 10:25:11 CEST 2019
Am 15.08.2019 um 00:39 schrieb Jean SUZINEAU:
> Le 14/08/2019 à 23:18, Martin a écrit :
>> inc(CALL_LVL [ LOCAL_CALL ],1)
>>
>> Yes, "inc" does not work for properties. But neither does +=.
>
> I agree and in the case of a property I think it would be cleaner to
> code an Inc method directly in the class, or eventually in a class
> helper, to write something like:
>
> CALL_LVL [ LOCAL_CALL ].Inc(1)
>
> In case of property, it's likely that you'll even be able to optimize
> the code, trimming some lines of the getter and the setter in you Inc
> method.
Please note that this won't work if CALL_LVL is a property and the
returned type is a record is the returned value will be a temporary
variable, thus you'd increase the value of the temp, but not of the one
stored in the class.
Regards,
Sven
More information about the fpc-pascal
mailing list