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,be018246a766b23 X-Google-Attributes: gid103376,public From: nobody@REPLAY.COM (Anonymous) Subject: Re: Private declaration question Date: 1997/06/10 Message-ID: <199706101323.PAA26477@basement.replay.com>#1/1 X-Deja-AN: 247452917 References: <865912531.32snx@jvdsys.nextjk.stuyts.nl> Organization: Replay and Company UnLimited X-001: Replay may or may not approve of the content of this posting Mail-To-News-Contact: postmaster@nym.alias.net X-002: Report misuse of this automated service to X-URL: http://www.replay.com/remailer/ Newsgroups: comp.lang.ada Date: 1997-06-10T00:00:00+00:00 List-Id: On Tue, 10 Jun 97 03:15:31 GMT, jerry@jvdsys.nextjk.stuyts.nl (Jerry van Dijk) wrote: > Why has the completion of a private declaration to be a full view ? > > 1. package Oops is > 2. > 3. type A_Type is limited private; > 4. > 5. private > 6. > 7. type A_Type is array (Positive range <>) of Integer; > | > >>> full view of type must be definite subtype > > After browsing the RM I think the error message comes from rule > 7.3(4). If that is true, why is this ? It seems a logical construction > to protect A_Type objects from user interference. > > -- > > -- Jerry van Dijk | Leiden, Holland > -- Consultant | Team Ada > -- Ordina Finance | jdijk@acm.org > > No, the correct ARM reference is 3.3(23): A subtype is an indefinite subtype if it is an unconstrained array subtype, or if it has unknown discriminants or unconstrained discriminants without defaults (see 3.7); otherwise the subtype is a definite subtype (all elementary subtypes are definite subtypes). The problem here is that the language allows a client of Oops to declare and object of type A_Type: Object : Oops.A_Type; However, the full view of the type is an unconstrained array type, and such an object declaration is illegal. It's the same as declaring Object : String; You can't do this; you have to supply a definite subtype, either explicitly subtype Name is String (27 .. 358); Object : Name; or implicitly Object : String (42 .. 71); However, there's no way for the client to know that Oops.A_Type needs constraining, nor to constrain it. You have several choices: 1. Make the private view of Oops.A_Type indefinite by adding the an unknown discriminant: type A_Type (<>) is limited private; 2. Make the full view definite: type A_Type is array (Positive range 1 .. 77) of Integer; 3. Do something else. This covers a lot of territory, including having the full view be a discriminated record type with default discriminants, or having the full view be an extension of Ada.Finalization.Controlled with a component of an access type that designates the unconstrained array type. Jeff Carter PGP:1024/440FBE21 My real e-mail address: ( carter @ innocon . com ) "Now go away, or I shall taunt you a second time." Monty Python & the Holy Grail Posted with Spam Hater - see http://www.compulink.co.uk/~net-services/spam/