[fpc-devel] Less global variables

Hans-Peter Diettrich DrDiettrich1 at aol.com
Sat Oct 9 22:18:29 CEST 2010


Adem schrieb:
>  On 2010-10-09 16:22, Hans-Peter Diettrich wrote:
>> The variables have been replaced by (getter) functions, with some 
>> added procedures for updating their values - this is where 
>> getter/setter pairs are inapplicable for structured types, or require 
>> too many consequential changes for using pointers instead of plain 
>> variables. If somebody can suggest a less intrusive solution, more 
>> global variables can be moved.
> Would you consider turning those structured types into objects?

This solution has some limitations. The conversion of a packed record 
requires much coding, the fields can not be used as var parameters and 
cannot be inc'ed etc. And then there is the time required to create and 
destroy the objects. In former attempts I converted the getters to 
return pointers instead of values, to overcome these problems, but then 
*every* usage of such a variable has to be modified accordingly - what I 
wanted to avoid this time.

> Properties with getter/setter pairs would make tracing (placing a 
> breakpoint in the getter/sertter would help identify the caller) easier.

Static analysis is easier with different names for the "setters". In 
many cases specialized setters can replace more than a single statement.

DoDi




More information about the fpc-devel mailing list