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 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,103b407e8b68350b X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-01-15 15:39:13 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!cyclone.bc.net!sjc70.webusenet.com!c03.atl99!cyclone2.usenetserver.com!news.webusenet.com!news-hub.cableinet.net!blueyonder!internal-news-hub.cableinet.net!news-text.cableinet.net.POSTED!53ab2750!not-for-mail User-Agent: Microsoft-Entourage/10.1.1.2418 Subject: Re: Anybody in US using ADA ? One silly idea.. From: Bill Findlay Newsgroups: comp.lang.ada Message-ID: References: <1041908422.928308@master.nyc.kbcfp.com> <1041997309.165001@master.nyc.kbcfp.com> <1042086217.253468@master.nyc.kbcfp.com> <1042477504.547640@master.nyc.kbcfp.com> <1042651417.215661@master.nyc.kbcfp.com> <1042657338.377677@master.nyc.kbcfp.com> Mime-version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-transfer-encoding: 7bit Date: Wed, 15 Jan 2003 23:39:12 GMT NNTP-Posting-Host: 80.195.52.70 X-Complaints-To: abuse@blueyonder.co.uk X-Trace: news-text.cableinet.net 1042673952 80.195.52.70 (Wed, 15 Jan 2003 23:39:12 GMT) NNTP-Posting-Date: Wed, 15 Jan 2003 23:39:12 GMT Organization: blueyonder (post doesn't reflect views of blueyonder) Xref: archiver1.google.com comp.lang.ada:33056 Date: 2003-01-15T23:39:12+00:00 List-Id: On 15/1/03 22:51, in article AAlV9.4495$K63.158061@newsfep1-gui.server.ntli.net, "chris.danx" wrote: > Bill Findlay wrote: >> On 15/1/03 19:02, in article 1042657338.377677@master.nyc.kbcfp.com, "Hyman >> Rosen" wrote: > >>> Oh, that's interesting, I didn't know that. >>> Can I then have arrays whose index type is >>> this dynamic subtype? Can I have records >>> which have such arrays as components? > >> Yes! >> In the record case, an array field bound can even be the value of another >> (discriminant) field of the same record. >> 8-) > > Pardon my stupidity but how do you do this? If this is what it sounds > like, it might be an ideal solution to a problem I've encountered. I refer my learned friend to Cohen, "Ada as a second language", pp 379 et.seq. Here is the gist of the first example. (N.B. Untested code!): type Int_Array_Type is array(Positive range <>) of Integer; ... type Int_Stack_Type (Max : Positive) is record Top : Natural := 0; Data : Int_Array_Type (1..Max); -- N.B. Only "Max" is allowed, even "Max+1" is illegal here end record; ... N : Positive := Read; -- N.B. N's value is read in ... subtype Stack_Of_Ints is Int_Stack_Type (N*(N+1)/2); ... Illegal_Stack : Int_Stack_Type; -- ILLEGAL, Max has no value Legal_Stack_1 : Int_Stack_Type (N*(N+1)/2); Legal_Stack_2 : Stack_Of_Ints; -- Bill-Findlay chez blue-yonder.co.uk ("-" => "")