[Lazarus] Code completion: Error: ancestor has same name as class.

Marcos Douglas md at delfire.net
Sun Mar 6 16:00:06 CET 2011


On Sun, Mar 6, 2011 at 6:20 AM, Juha Manninen <juha.manninen62 at gmail.com> wrote:
> Marcos Douglas kirjoitti sunnuntai 06 maaliskuu 2011 03:57:02:
>> type
>>   TStringList = class(Classes.TStringList)
>>   public
>>     function Foo: string;
>>   end;
>
> In any case your class name is very confusing. I would always use a different
> name. When someone else reads your code and sees TStringList he assumes it is
> a "normal" TStringList.

It was just an example.
But there is an advantage, see below.

On Sun, Mar 6, 2011 at 4:47 AM, Mattias Gaertner
<nc-gaertnma at netcologne.de> wrote:
> The codetools have no circle detection when searching
> recursively. As a simple protection versus endless loops they do not
> support naming classes the same as their ancestort.
> And I agree with Juha, it is bad coding practice.

If you have a program with a lot of TEdit and you have to modify some
feature (eg: when the Edit give the focus, your color will change) you
can codify this new feature in your own unit (eg mystrctrls.pas) and
you can put the new unit on uses clause (at the end or after on "real"
unit of TEdit) and voialá! You have a "new" TEdit in runtime.

Nobody did that??


Marcos Douglas




More information about the Lazarus mailing list