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!newsfeeds.sol.net!posts.news.twtelecom.net!nnrp2.twtelecom.net!not-for-mail From: "Matthew Heaney" Newsgroups: comp.lang.ada References: Subject: Re: Idiom for a class and an object in Ada Date: Mon, 18 Oct 2004 12:59:39 -0400 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1437 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 Message-ID: <4173f39c$0$91005$39cecf19@news.twtelecom.net> Organization: Time-Warner Telecom NNTP-Posting-Date: 18 Oct 2004 16:47:24 GMT NNTP-Posting-Host: 5876444f.news.twtelecom.net X-Trace: DXC=iZBU>R2E3F>RB35k`Hh4L;C_A=>8kQj6=hHXa^^g6TZ4QgCbG[n49S8dYZAA8S: "Marin David Condic" wrote in message news:M3Ocd.237$5i5.72@newsread2.news.atl.earthlink.net... > 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? See for example the packages Data_Maps and Relation_Maps in the genealogy examples in the ai302 examples subdirectory: The idea is to create a limited private type with an unknown discriminant: package Data_Maps is type Map (<>) is limited private; ... -- operations here function Dates return Map; function Places return Map; private ... -- see code for implementation end; This is similar to how Standard_Input, Standard_Output, etc are implemented in Text_IO.