[lazarus] Name Confilct in fpc

vital at videotron.ca vital at videotron.ca
Tue Feb 29 19:26:21 EST 2000


At 18:16 00-02-29 +0100, you wrote:
>Michael Van Canneyt wrote:
>> > The other thing I found after this which Delphi will happily handle
>> > but which fpc throws up on.....
>> >
>> > type
>> >   TSomeObject = class(TObject)
>> >   private
>> >     FSomeVar: TSomeType;
>> >     ........
>> >   public
>> >     procedure DontWork(Dummy: String; SomeVar: TSomeType);
>> >     procedure ......
>> >   published
>> >     property SomeVar: TSomeType Read FSomeVar;
>> >   end;
>> >
>> > The Fix is easy...
>> >
>> > procedure DontWork(Dummy: String; aSomeVar: TSomeType);
>> 
>> This is done deliberately. We feel that having the same name in a
>> parameter of a method and a property name is very bad coding and
>> should not be allowed. This is, of course, debatable since you could
>> e.g. argue that the procedure starts a new scope, and that within
>> this scope you can redefine any symbol etc etc etc...
>> 
>
>But this would also apply for methods and fields but parameters
>can't have the same name as methods and fields.

I dont sea why this shouln't be allowed since there's no realy conflic.
When there are a parameter which have the same name of a property or
variable member those 2 simple rules apply inside the methode.


  1. When using the name alone it refer to the parameter
  2. When the name is preceding with 'Self' keyword + '.' , 
     it refer to the property or variable member.

Sea exemple:

procedure TSomeObject.DontWork(Dummy: String; SomeVar: TSomeType);
Begin
  Somethink := SomeVar;      // SomeVar = Parameter
  Somethink := Self.SomeVar; // SomeVar = Property of TSomeObject
And;

There's no such ambiguity and why whould it need such restriction?

My $0.02

Vital Tremblay
vital at videotron.ca






More information about the Lazarus mailing list