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/01 Message-ID: #1/1 X-Deja-AN: 450047991 Sender: matt@mheaney.ni.net References: <7b1k4h$13k6@news3.newsguy.com> <7b4517$2bbr@news3.newsguy.com> <7be1p0$mjg$4@plug.news.pipex.net> NNTP-Posting-Date: Mon, 01 Mar 1999 10:44:03 PDT Newsgroups: comp.lang.ada Date: 1999-03-01T00:00:00+00:00 List-Id: "Nick Roberts" writes: > One little detail is that the primitive operations of T should all (with > possible exceptions) be made abstract, since T is only a 'signature' type, > e.g.: > > package P is > > type T (<>) is abstract tagged limited private; > > > > type T_Access is access all T'Class; > > function Ref return T_Access is abstract; This is wrong. Function Ref is NOT a primitive operation for type T. It's just a way of returning a pointer to the object declared in the body. To use the scheme I've shown, you'd have to do this: declare Singleton : Singleton_Type renames Ref.all; begin Do_Something (Singleton); Do_Something_Else (Singleton); ... end; A simpler technique is to make the primitive operations of the type take access parameters, so then you won't have to dereference the pointer: function Singleton return T_Access; ... Do_Something (Singleton); Do_Something_Else (Singleton);