[fpc-devel] Local variable names and colision with attributes/properties names

Michael Van Canneyt michael at freepascal.org
Thu Sep 27 18:48:52 CEST 2012



On Thu, 27 Sep 2012, Marcos Douglas wrote:

> On Thu, Sep 27, 2012 at 12:08 PM,  <michael.vancanneyt at wisa.be> wrote:
>>
>>
>> On Thu, 27 Sep 2012, Marcos Douglas wrote:
>>
>>>>
>>>> Yes, it's always possible. In practice, I haven't seen this happen a
>>>> single
>>>> time in the 10+ years that the compiler has had this feature. That
>>>> doesn't
>>>> mean that it's impossible, but it's another factor in the "good to have"
>>>> versus "causes more harm than good" equation.
>>>
>>>
>>> Well, happened on the own compiler.  ;-)
>>> IMHO, these collisions happen a lot and because of this many
>>> programmers use prefixes in local variables, see:
>>> lNet, fpGUI, tiOPF2, Indy, and even Delphi (DateUtils unit eg.).
>>
>>
>> Exactly.
>>
>> The compiler helps you by forcing you to use a prefix in objfpc mode in case
>> you forgot.
>
> The collisions exist because the compiler give us an error. 
> If the compiler respect the scope, the collisions would not exist.

I know there is no collision in the strict sense of the word. 
There is just the very real possibility of making human mistakes.

> However we can use "poor names" -- very difficult to happen a
> collision -- to represent a variable like A, J, D... but I do not
> think this is a good practice and you?

I do think this is good practice. 
I will seldom use variable names of more than 2 characters.

Michael.



More information about the fpc-devel mailing list