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,be018246a766b23 X-Google-Attributes: gid103376,public From: "John G. Volan" Subject: Re: Private declaration question Date: 1997/06/10 Message-ID: <339E062E.2BC4@sprintmail.com>#1/1 X-Deja-AN: 247582251 References: <5nibkg$p9t$1@goanna.cs.rmit.edu.au> <865993476.33snx@jvdsys.nextjk.stuyts.nl> Reply-To: johnvolan@sprintmail.com Newsgroups: comp.lang.ada Date: 1997-06-10T00:00:00+00:00 List-Id: Jerry van Dijk wrote: > > However both GNAT and ObjectAda accept: > > type A_type (<>) is limited private; > ... > private > type A_Type is array (Positive range <>, Positive range <>) of Integer; > > but of course fail when trying to create an A_Type object. > > Any idea's ? (1) You can provide one or more functions that return A_Type: type A_Type (<>) is limited private; function Make_A (Length, Width : in Natural; Value : in Integer) return A_Type; ... private type A_Type is array (Positive range <>, Positive range <>) of Integer; which can be implemented as, e.g.: function Make_A (Length, Width : in Natural; Value : in Integer) return A_Type is begin return A_Type (1 .. Length, 1 .. Width)'(others => Value); end Make_A; and which a client can utilize within the initialization of a object declaration, e.g.: Clients_A : A_Type := Make_A (Clients_Length, Clients_Width, Clients_Value); (2) Instead of declaring A_Type with unknown discriminants, give it known discriminants: type A_Type (Length, Width : Natural) is private; ... private type A_Content_Type is array (Positive range <>, Positive range <>) of Integer; type A_Type (Length, Width : Natural) is record Content : A_Content_Type (1 .. Length, 1 .. Width); end record; ------------------------------------------------------------------------ Internet.Usenet.Put_Signature (Name => "John G. Volan", Employer => "Texas Instruments Advanced C3I Systems, San Jose, CA", Work_Email => "johnv@ti.com", Home_Email => "johnvolan@sprintmail.com", Slogan => "Ada95: World's *FIRST* International-Standard OOPL", Disclaimer => "My employer never defined these opinions, so using " & "them would be totally erroneous...or is that just " & "nondeterministic behavior now? :-) "); ------------------------------------------------------------------------