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/03/02 Message-ID: #1/1 X-Deja-AN: 450312244 Sender: matt@mheaney.ni.net References: <7b1k4h$13k6@news3.newsguy.com> <36daf246.1947172@news.pacbell.net> <36db6723.31869063@news.pacbell.net> <36dba095.13738466@news.pacbell.net> NNTP-Posting-Date: Tue, 02 Mar 1999 02:29:27 PDT Newsgroups: comp.lang.ada Date: 1999-03-02T00:00:00+00:00 List-Id: tmoran@bix.com (Tom Moran) writes: > >If there is a derived type, it's within the package hierarchy: > > >package P is > > > type T (<>) is abstract tagged limited private; > But what about > with P; > package Q is > type Son_Of_T is new P.T with ... No, there is no such thing. Outside the package hierarchy, there'd be no way to create an instance of Son_Of_T. > Or does the original question *only* refer to > >package P.C is Yes, this is the case. Derivations only occur in children of P. > > type NT is new T with private; > In which case, why even have T in the public part of P? It could be > in the private part, where it's visible to P.C, and not visible to > 'outsiders'. If you restrict T to being extended only in children of > P, then it can be private, and the original question disappears. No. You're forgetting that clients are still manipulating a singleton instance of the derived type. This is a public object, of a public type, with public operations. That NT derives from T is a public feature of the type, not an implementation detail. Of course, you could do it the way you suggest. This is sort of an extreme example, where you have a family of types, and each type in the family has a singleton instance. I don't know why Don wants to do this (I've certainly never had such a need), but I wanted to show that it is possible, and that in fact the implementation is relatively simple. It will take some time for programmers to grok the concept of limited and indefinite types, and what it's buying you. I have a few examples of this idiom in the ACM patterns archive. I'm working on another pattern now that was inspired by this thread. An abstract factory, implemented using smart pointers, is used to initialize a singleton instance of a limited and indefinite type. Whew! I'll post an announcement on CLA once it has been submitted (probably tomorrow or the day after.)