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=0.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,772ae8afc5db35f2 X-Google-Attributes: gid103376,public From: nospam@thanks.com.au (Don Harrison) Subject: Re: Can't export object of private type Date: 1999/03/01 Message-ID: #1/1 X-Deja-AN: 449718843 Sender: news@syd.csa.com.au X-Nntp-Posting-Host: dev7 References: <7b8cvc$ii5$3@plug.news.pipex.net> Organization: CSC Australia, Sydney Reply-To: nospam@thanks.com.au Newsgroups: comp.lang.ada Date: 1999-03-01T00:00:00+00:00 List-Id: Nick Roberts wrote: : package Planetary is ... : type Planet_Id is private; ... : private : ... : end Planetary; The problem here is that you lose the property of having a single instance: > 1) Have only one instance Since Planet_Id is exported, anyone can declare an object of that type. We want to ensure there is only a single instance shared by all clients. :Another possible scheme that might suit you is: (a) declare a limited tagged :type which is derived from Finalization.Limited_Controlled; (b) implement :Initialize so that it increments a counter (which is itself initialized to :0), and if it goes above 1 (or some other number), raise an exception; (c) :implement Finalize so it decrements the counter. This way you can :polymorphise the type as normal, but be sure no more than one object of the :type exists at any one time. Interesting idea. However, static enforcement would be preferable. We should expand 1): > 1) Have only one instance (enforced statically) -- Don (Harrison). donh at syd.csa.com.au