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,2afac1a4161c7f35 X-Google-Attributes: gid103376,public From: mheaney@ni.net (Matthew Heaney) Subject: Re: Distinguishing type names from other identifiers Date: 1998/01/27 Message-ID: #1/1 X-Deja-AN: 319890558 Content-Transfer-Encoding: 8bit References: <01bd2078$a449b460$41fd82c1@xhv46.dial.pipex.com> <6v0LMGAjwIw0Ews0@dowie-cs.demon.co.uk> Content-Type: text/plain; charset=ISO-8859-1 Organization: Estormza Software Mime-Version: 1.0 Newsgroups: comp.lang.ada Date: 1998-01-27T00:00:00+00:00 List-Id: In article , Brian Rogoff wrote: >Use of the type suffix makes it fairly easy to choose consistent names, >especially for the common case where there is only one variable of the >type. So where someone might write > > The_Object : Object; > >I would write something like > > Object : Object_Type; > >and I never have collisions between type and variable names. In generic >code, choosing specific names (as Matthew Heaney suggested, I think) >becomes much harder, the code is generic after all. This convention also >makes it easy to write source analysis tools which get type names by >simple lexical analysis, and, IMO, is easy on the eyes. I agree, it is >redundant, but then so are comments, readable names, the distinction in >Ada between functions and procedures ;-), ... In practice, names for generic types aren't any harder either. The convention I use is something like generic type Stack_Item is private; with function "=" (L, R : Stack_Item) return Boolean is <>; package Stacks is type Root_Stack is abstract tagged null record; function Top (Stack : Root_Stack) return Stack_Item; ... end Stacks; I have seen people use _Type for the generic formal type, ie generic type Item_Type is private; ... package Stacks is ...; Here's one case where I'd concede that the _Type convention makes sense, because you want to emphasize the inchoate character of the formal type. But I pretty much use the adjective+noun convention for formal types too, for consistency. Another example is importing an active iterator as a generic formal type: generic Max_Depth : in Positive; package Stacks.Bounded is type Bounded_Stack is new Root_Stack with private; ... generic type Source_Stack is new Root_Stack with private; type Source_Stack_Iterator (Stack : access Source_Stack'Class) is new Root_Stack_Iterator with private; procedure Generic_Copy (From : access Source_Stack'Class; To : in out Bounded_Stack); end Stacks.Bounded; Boy oh boy, I really, really wish we had access constant parameters and discriminants. Oh well. -------------------------------------------------------------------- Matthew Heaney Software Development Consultant (818) 985-1271