From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,63a41ccea0fc803a X-Google-Attributes: gid103376,public From: Matthew Heaney Subject: Re: Naming of Tagged Types and Associated Packages Date: 1998/08/05 Message-ID: #1/1 X-Deja-AN: 378211952 Sender: matt@mheaney.ni.net References: NNTP-Posting-Date: Wed, 05 Aug 1998 09:33:44 PDT Newsgroups: comp.lang.ada Date: 1998-08-05T00:00:00+00:00 List-Id: nospam@thanks.com.au (Don Harrison) writes: > I think it's not so much namespaces but the fact that the syntax allows > you (and the compiler) to easily differentiate variables (entities in > Eiffel parlance) from types. > > Some examples.. > > 1) Variable declarations: > > variable : TYPE > > The identifier to the left of the colon is recognised as a variable > and the one on the right as a type. But this is true in Ada too. The issue in Ada is that once an identifier appears in a declaration, it can't appear again in the same declaration. So the declaration declare File : File; begin is illegal in Ada, even though the compiler knows that the identifier on the left denotes an object, and the identifier on the right a type. The same is true for function invokations (aka "constructors") that appear in a declaration. The declaration declare Top : Integer renames Top (Integer_Stack); begin is illegal, because of the name clash between object Top and selector Top. That's why I usually name selectors Get_xxx, to avoid namespace conflicts inside a declaration. The declaration declare Top : Integer renames Get_Top (Integer_Stack); begin is now legal. I argue that different names should be used for an object and its type in a declaraion, in order to prevent namespace clashes. I don't think an expanded name (ie P.T) should be used for this purpose. I make this argument based on a careful reading of the RM. File_Type is called that precisely because an object of that type will most likely be called File. Had the designers intended for expanded name notation to always be used for the type in an object declaration, in order to resolve a name clash, then File_Type would have been named just File. As much as possible, I like to stick to the naming conventions in the RM. But this is my model. For others, consistency with RM conventions isn't a compelling enough argument. Oh, well.