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

Mattias Gaertner nc-gaertnma at netcologne.de
Thu Sep 27 19:18:50 CEST 2012


On Thu, 27 Sep 2012 13:52:53 -0300
Marcos Douglas <md at delfire.net> wrote:

> On Thu, Sep 27, 2012 at 12:34 PM, Graeme Geldenhuys
> <graeme at geldenhuys.co.uk> wrote:
> > On 2012-09-27 16:08, michael.vancanneyt at wisa.be wrote:
> >>
> >> The compiler helps you by forcing you to use a prefix in objfpc mode in
> >> case you forgot.
> >
> > The change in FPC mode objfpc was definitely a good thing. I had code
> > where a class had an Index property, and other methods of that class had
> > an Index parameter name. Even though it was my own code, I had to triple
> > check the method's implementation to find the real meaning when I used
> > the Index identifier somewhere in that method.
> >
> > Now with the new language rule, I don't have such issues any more. Index
> > will be the property name, AIndex will be the parameter, lIndex will be
> > a local variable. Much simpler for my brain to process. :)
> 
> I never said this is wrong. I just said that could be a compiler
> directive or something like that.
> 
> I agree that is much simpler... but why nobody, in another language,
> do the same? Does not worth it? I do not know.

Just an example:
In Java the name clash is allowed. In the courses I attended many
students confuse their variables so much that they think they
must always prepend "this" to all member variables. 
So instead of prepending the parameters, they prepend the
members.
This is one of the most confused "features" of Java.

I'm glad objfpc is less ambiguous than mode Delphi.

Mattias



More information about the fpc-devel mailing list