[Lazarus] Namespace

Marcos Douglas md at delfire.net
Wed Jan 12 17:48:54 CET 2011


On Wed, Jan 12, 2011 at 1:18 PM, Alexander Klenin <klenin at gmail.com> wrote:
> On Wed, Jan 12, 2011 at 21:09, Marcos Douglas <md at delfire.net> wrote:
>> On Tue, Jan 11, 2011 at 6:03 PM, Hans-Peter Diettrich
>> <DrDiettrich1 at aol.com> wrote:
>>> Duplicate identifiers are used in the same unit in very rare cases only, so
>>> that normally a qualification is not necessary at all.
>>
>> Rare cases because I can't use the identifiers TEdit, TButton, etc.
>> Then we always will have to invent prefixes for new widgets?
>
> If you invent a new button, then I guess naming it TButton
> will be confusing regardless of chosen namespace, since
> TButton is a well-known name for any Delphi/Lazarus developer.

Yes, but this was just an example.
Another example: A while ago I used the prefix "dx", but then I
discovered that DevExpress.com already using this prefix.
So, I really would not use TButton or TEdit... but if we want, we could not use?

I think it's harder to have conflicts with the names of units (but
they do happen) than with class names.

And if we can "rename", in the code, the names of the units then it
would be perfect, IMHO.

Like this:

uses
  CompanyXYZ_StdCtrls as xyzctrls;

var
  b: TButton;
begin
  b := xyzctrls.TButton.Create(Self);
  // some code
end;

We could have big names of units (much less naming conflicts), but
with a very lean code.

Just my 2 cents.


Marcos Douglas




More information about the Lazarus mailing list