[Lazarus] Namespace

Michael Van Canneyt michael at freepascal.org
Mon Jan 10 20:34:34 CET 2011



On Mon, 10 Jan 2011, Marcos Douglas wrote:

> On Mon, Jan 10, 2011 at 9:43 AM, Hans-Peter Diettrich
> <DrDiettrich1 at aol.com> wrote:
>> Marcos Douglas schrieb:
>>
>>> I'm not talk about RTTI but style, make code more readable and less
>>> duplication of names.
>>
>> Working with items of the same name, from different locations (units,
>> namespaces), requires qualifications all over. That waste of characters in
>> source code makes code less readable to me.
>
> Waste of characters? Not really. Write xyz.TFoo is not so different of
> TxyzFoo. There is one char more.
> How I will know all prefixes of all libs in the internet? If I choose
> the prefix "rx", I will have conflicts with RXlib, for example.
> Graeme chose the same prefix the Lazarus did in some classes:
> TfpgXXXX   ("fpg")

The prefix is not needed. It makes it easier, but is by no means a 
requirement, as long as you keep the unit names separate.

Compare

   Edit1 : myedit.tedit

to

   Edit1 : tmyedit

In the second case, you'll cover 99% of all cases.

If by any chance there is an overlap, then the first scenario

   edit1 : myedit.tmmyedit

is still an option.

I work 12 years with lots of libraries, and I have exactly once (1 !) 
encountered a problem with duplicate names; when Delphi introduced strutils, 
it clashed with rxlib's strutils, which was subsequently renamed to rxstrutils.
problem solved.

So namespaces: yes, nice to have.

But do they solve an urgent problem ? I don't think so.

Michael.




More information about the Lazarus mailing list