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.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,f20f5dfbb5c26c12 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-12-02 16:06:46 PST Path: archiver1.google.com!news2.google.com!news.maxwell.syr.edu!small1.nntp.aus1.giganews.com!border1.nntp.aus1.giganews.com!intern1.nntp.aus1.giganews.com!nntp.giganews.com!nntp.comcast.com!news.comcast.com.POSTED!not-for-mail NNTP-Posting-Date: Tue, 02 Dec 2003 18:06:43 -0600 Date: Tue, 02 Dec 2003 19:06:42 -0500 From: "Robert I. Eachus" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax) X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: discriminant in constraint must appear alone References: In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: NNTP-Posting-Host: 24.34.214.193 X-Trace: sv3-PKgJI7DFPHTiIsCyAFMjvYyTQTvb3IU7HXNf7fooSynDrMNn+W2tX24vHM/RFfgeszRBS7YpQVyLvpD!EiS4rVrbyv8li694+s9hTp2XKg1BxkxPcwuQ1soHD7OyMFO9BWt6EoHyMHpcWQ== X-Complaints-To: abuse@comcast.net X-DMCA-Complaints-To: dmca@comcast.net X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.1 Xref: archiver1.google.com comp.lang.ada:3083 Date: 2003-12-02T19:06:42-05:00 List-Id: Vincent Smeets wrote: > Are there other possiblities? There are always other possibilities. ;-) In this case the rule (RM 3.8(12) is clear on how discriminants can appear in a record type. You could try: type R (D2 : Positive) is record A1 : String (1 .. D); A2 : String (1 .. D); B : String (1 .. D); end record; Where A = A1 & A2, and D2 = D/2, or you could use aliasing to map a string on top of an array (1..D) of Integer_16 elements. But I think the only reasonable approach for now is to have two discriminants. Incidently I have tripped over this problem in the past, and I think it would be wonderful to add three possible uses of discriminants in array bounds: -D, D + n and n * D, where n is an integer literal. Except for the first case, a compiler has to be able to generate these types of expressions and evaluate them at run-time. For example, where does the value of B start in the type above? Probably at 2*D + 4 bytes from the start of an object of type R. (Your milage may vary, I am assuming that for this type the bounds of the arrays are implicit, but that D2 is stored at the beginning of any objects.) -- Robert I. Eachus 100% Ada, no bugs--the only way to create software.