[Lazarus] Nested Classes used as Namespace Issue

Razvan Adrian Bogdan lightningflash at gmail.com
Tue Jan 11 14:49:56 CET 2011


On Mon, Jan 10, 2011 at 9:48 PM, Sven Barth <pascaldragon at googlemail.com>wrote:

> In Pascal all type declarations appear in blocks that are named "type".
> This is the case in global unit scope, in local method scope and in class
> scope as well. So I don't think one should brake with the way Pascal works
> just to create code that looks more beautiful.
>
> And this is also Delphi compatible.


Yes i agree this is indeed how it works, what i meant was: Why not do it the
same way the Records work.
You can nest records and you don't use the type keyword for the nested
records, the parser/compiler knows how to recognize a "subrecord". By making
the type keyword optional you don't break anything and the compiler isn't
confused and it is the way records work already and this behavior is much
older and cleaner than the way it's implemented now.


 type
   TMyStruct = record
     NestedStruct = record
       SimpleMember: string;
     end;
   end;

 Just replace record with class and no type keyword is required, it's
simple, clean and not ambiguous in any way. For declaring other types inside
the class is would probably require the type keyword just not for nested
classes/records.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20110111/e04173bc/attachment-0003.html>


More information about the Lazarus mailing list