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 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,901038687c38f61c X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!news.glorb.com!border1.nntp.dca.giganews.com!nntp.giganews.com!peer01.cox.net!cox.net!newsfeeds.sol.net!posts.news.twtelecom.net!nnrp3.twtelecom.net!not-for-mail From: "Matthew Heaney" Newsgroups: comp.lang.ada References: <9175719.eWmeGlFrVu@linux1.krischik.com> Subject: Re: Idiom for a class and an object in Ada Date: Tue, 19 Oct 2004 11:52:36 -0400 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.2180 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 X-RFC2646: Format=Flowed; Response Message-ID: <41753563$0$74186$39cecf19@news.twtelecom.net> Organization: Time-Warner Telecom NNTP-Posting-Date: 19 Oct 2004 15:40:19 GMT NNTP-Posting-Host: f42b615c.news.twtelecom.net X-Trace: DXC=jOhhnIVi9XbIUHdLb3W^LeC_A=>8kQj6mMOj3YM9`=ahco=dW1mZJ3bdYZAA8S: "Marin David Condic" wrote in message news:Oc8dd.2347$ta5.1598@newsread3.news.atl.earthlink.net... > So you would do something that looked like this: > > package AD_Converter_Class_And_Objects is > > type AD_Converter is tagged private ; > > procedure Some_Op (AD : in out AD_Converter) ; > > AD_Number_1 : AD_Converter ; > > private > --stuff > end AD_Converter_Class_And_Objects ; Well, obviously this won't work, since you can't declare object AD_Number_1 prior to declaration of the full view of private type AD_Converter. And why did you name the package "...Class_And_Objects". Don't you mean "...Type_And_Objects"? This is very, very confusing! > Similarly if I had a half-dozen of these puppies? If I had only one, you'd > want to hide it in the package body and make the package be an object > instead of a class? What do you mean "instead of a class"? Do you mean "type" or "class"? If you mean "type", then why don't you say that? > Would there be a reason to prefer making a child package to contain one or > more objects of the class? Or a separate child package for each object? Do you mean one or more "objects of the type"? Why are you saying "class" here? This is very, very confusing! > There could be plusses and minuses to any given approach. I'm mostly > wondering what most Ada programmers prefer or tend to use. I showed you how to do this in another post. Declare the type as limited an indefinite, and provide functions that return a references to the statically-declared objects. Just like Text_IO.