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.3 required=5.0 tests=BAYES_00,INVALID_MSGID 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: Matthew Heaney Subject: Re: Can't export object of private type Date: 1999/02/28 Message-ID: #1/1 X-Deja-AN: 449654340 Sender: matt@mheaney.ni.net References: <7b47m3$l2l$1@remarQ.com> NNTP-Posting-Date: Sun, 28 Feb 1999 14:20:57 PDT Newsgroups: comp.lang.ada Date: 1999-02-28T00:00:00+00:00 List-Id: nospam@thanks.com.au (Don Harrison) writes: > :What about a parameterless function that returns that type? > > This seems closest to what I'm after so far. The possible weaknesses are: > > 1) Having to prefix them with package names to disambiguate > specific derivations: > > .. := T.Solo; > .. := T.Child.Solo; > > (I'm attempting to avoid package prefixes altogether, but perhaps > this is a vain hope). No, you don't need package prefixes. Declare the type as tagged, limited and indefinite, and have the root-level package export a function that returns a class-wide object (or a pointer to a class-wide object), and then you'll dispatch. Examples of how to do this are in the patterns archive at the ACM. Search for singleton, factory method, abstract factory. I was still learning Ada95 at the time I wrote some of that stuff (I've since improved it), so if anything's unclear, just drop me a note. Matt