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!border2.nntp.dca.giganews.com!nntp.giganews.com!elnk-atl-nf1!newsfeed.earthlink.net!stamper.news.atl.earthlink.net!newsread3.news.atl.earthlink.net.POSTED!d9c68f36!not-for-mail From: Marin David Condic User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.2) Gecko/20040804 Netscape/7.2 (ax) X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Idiom for a class and an object in Ada References: In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: Date: Tue, 19 Oct 2004 12:38:15 GMT NNTP-Posting-Host: 209.165.3.210 X-Complaints-To: abuse@earthlink.net X-Trace: newsread3.news.atl.earthlink.net 1098189495 209.165.3.210 (Tue, 19 Oct 2004 05:38:15 PDT) NNTP-Posting-Date: Tue, 19 Oct 2004 05:38:15 PDT Organization: EarthLink Inc. -- http://www.EarthLink.net Xref: g2news1.google.com comp.lang.ada:5447 Date: 2004-10-19T12:38:15+00:00 List-Id: Well, that's one approach. I'd prefer to avoid the code bloat of a generic when all I really need to duplicate is the data. Also, its tougher to do any sort of inheritance going the generic route. I'm wondering specifically about the usual OOD idiom of making a class out of a package with a tagged record - such that it can be extended with another child class - and where is the "best" place to declare objects of that class? MDC Marius Amado Alves wrote: >> Suppose I have a class with one or a limited set of objects. The >> objects are "global" in the sense that they hang around from program >> startup thru the entire life of execution. An example would be an A/D >> Converter class - My little control box might have 3 or 4 A/Ds in it - >> they're always there and I want the data associated with them to be >> static (not declared on the stack.) >> >> Question: What is the preferred Ada idiom for defining such a creature? > > > generic > Line : Number; > package AD_Converter is > function OK return Boolean; > function Get return Value; > end; > > package Heat is new AD_Converter (123); > package Noise is new AD_Converter (456); > package Wind is new AD_Converter (789); > > -- You can't get more "static" than that! > -- ====================================================================== Marin David Condic I work for: http://www.belcan.com/ My project is: http://www.jsf.mil/NSFrames.htm Send Replies To: m o d c @ a m o g c n i c . r "Power corrupts. Absolute power is kind of neat" -- John Lehman, Secretary of the Navy 1981-1987 ======================================================================