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.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.107.139.214 with SMTP id n205mr12658629iod.103.1510015381694; Mon, 06 Nov 2017 16:43:01 -0800 (PST) X-Received: by 10.157.14.201 with SMTP id 67mr629763otj.4.1510015381537; Mon, 06 Nov 2017 16:43:01 -0800 (PST) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!news.fcku.it!peer03.fr7!futter-mich.highwinds-media.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!l196no82396itl.0!news-out.google.com!193ni75iti.0!nntp.google.com!l196no82394itl.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Mon, 6 Nov 2017 16:43:01 -0800 (PST) In-Reply-To: <87y3nkft3n.fsf@jacob-sparre.dk> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=173.71.208.22; posting-account=QF6XPQoAAABce2NyPxxDAaKdAkN6RgAf NNTP-Posting-Host: 173.71.208.22 References: <2689fb89-cbde-4d32-9944-4c4c10c34e5e@googlegroups.com> <87y3nkft3n.fsf@jacob-sparre.dk> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <2d066e87-8cf3-430d-b18f-9c834afe499d@googlegroups.com> Subject: Re: Tagged type naming convention From: Jere Injection-Date: Tue, 07 Nov 2017 00:43:01 +0000 Content-Type: text/plain; charset="UTF-8" X-Received-Body-CRC: 3564620931 X-Received-Bytes: 4675 Xref: news.eternal-september.org comp.lang.ada:48753 Date: 2017-11-06T16:43:01-08:00 List-Id: On Sunday, November 5, 2017 at 2:01:02 PM UTC-5, Jacob Sparre Andersen wrote: > Jere writes: > > > I was looking at an older document for a naming convention for tagged > > types and stumbled upon J.P. Rosen's "A Naming Convention for Classes > > in Ada 9X" [1]. It's pretty intriguing and, even though it was > > developed for 9X, it has applicability in the current Ada revision. > > However, I haven't really seen it employed in any of the libraries > > I've messed with. Keep in mind, my experience with external libraries > > is limited. I was curious if this style is something that a lot of > > people use and had some input on. Is it still in use? Pros/Cons > > based on experience using it? > > It is definitely still in use. I use it. That's good to hear. It does look like a nice pattern. > > > One concern for it is consistency. It was presented with tagged types > > in mind, but even non tagged types provide inheritance and primitive > > operations that can be overridden. Should it be applied to those as > > well if used? > > Only if you stick to the pattern of a single type per package. > > I only use Jean-Pierres's naming pattern for the primary type in a > package. Any "helper" types have more arbitrary names. > > Jean-Pierre's naming pattern is one of the two suggested in the Ada 95 > Quality and Style Guide. I actually have a couple of use cases where I might have multiple "main" types in a package. Given that possibility and also the possibility that I might want to define non-primative operations on a given type, I was tossing around the idea of merging the Rosen method with the one mentioned by Luke Guest. Something like: package Well_Named_Package is package A_Main_Type is type Instance is tagged private; subtype Class is Instance'Class; procedure Primitive_Op1(Object : Instance); procedure Primitive_Op2(Object : Instance); end A_Main_Type; package Another_Main_Type is type Instance is tagged private; subtype Class is Instance'Class; procedure Primitive_Op1(Object : Instance); procedure Primitive_Op2(Object : Instance); end Another_Main_Type; procedure Non_Primitive_Op1(Object : A_Main_Type.Instance); procedure Non_Primitive_Op2(Object : Another_Main_Type.Instance); procedure Non_Primitive_Op3 (Object1 : A_Main_Type.Instance; Object2 : Another_Main_Type.Instance); end Well_Named_Package; My main concern is that starts to look complex/noisy. But it gives me the ability to have multiple main types and keep the same naming convention. If I did that, however, I would want to keep packages with single main types looking consistent. At worst I would have something like this: package Well_Named_Package is package A_Main_Type is type Instance is tagged private; subtype Class is Instance'Class; procedure Primitive_Op1(Object : Instance); procedure Primitive_Op2(Object : Instance); end A_Main_Type; end Well_Named_Package; So then I would have a package in a package with no indication of why other than it is there to have consistency with the general case (multiple types and non primitive ops). Though I feel like I might be going overboard.