[Lazarus] Namespace

Marcos Douglas md at delfire.net
Mon Jan 10 11:17:16 CET 2011


On Sun, Jan 9, 2011 at 3:56 PM, Hans-Peter Diettrich
<DrDiettrich1 at aol.com> wrote:
> Marcos Douglas schrieb:
>>
>> If units are namespaces, why not use them in widgets declarations,
>> automatic, in Lazarus?
>> When we droped a widget in a Form, ie a TEdit, the declarion would be like
>> this:
>> TForm1 = class(Form)
>>  Edit1: StdCtrls.TEdit;
>> end;
>
> IMO control classes have to be registered, so that a compiled application
> can work independently from any namespace, unit or directory structure.
>
> That's why the first line above should read
>  Form1 = class(TForm)
> where Form1 is the name of the form object, as stored in the object itself,
> and TForm is the ClassName in the TForm.ClassType (vulgo VMT).
>
>> Why this? Well, we would not need to use prefixes in the names of our
>> widgets. I could develop a widget called TEdit too, but using my own
>> unit.
>
> All existing form objects are stored in Application.CustomForms[], and their
> controls in Form.Controls. Likewise the class names are usable via RTTI.
> Adding namespaces (or unit names) would require further table(s), that do
> not yet exist (except perhaps in debug info).

Hi Hans,
I'm not talk about RTTI but style, make code more readable and less
duplication of names.

Marcos Douglas




More information about the Lazarus mailing list