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.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,1cb75f0476fe2d1a X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsfeed.arcor.de!news.arcor.de!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Half Constrained Array Types and Slices Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.14.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: Date: Thu, 2 Mar 2006 09:34:26 +0100 Message-ID: <1q3lxr5byac4f$.x8dnc8mjzyj2.dlg@40tude.net> NNTP-Posting-Date: 02 Mar 2006 09:34:24 MET NNTP-Posting-Host: 2d7491c1.newsread4.arcor-online.net X-Trace: DXC=N11kE=Ra>R64B[hADX>N=3:ejgIfPPld4jW\KbG]kaM8Qc4L4[MA2T0RB`Rd>9_^P7[6LHn;2LCV>7enW;^6ZC`4IXm65S@:3>? X-Complaints-To: usenet-abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:3233 Date: 2006-03-02T09:34:24+01:00 List-Id: On Thu, 02 Mar 2006 05:00:06 GMT, Jeffrey R. Carter wrote: > Robert Duff present a concept from his idea for an Ada-like language (not called > Duff) some time ago, that there was no need for "box" ("<>") in his language: > > type String (Length : Natural) is array (1 .. Length) of Character; Not only this. Discriminants for arrays would also allow nice things like: type Table (Element_Size : Natural) is array (...) of String (1..Element_Size); or type Container (Element_Type : Tag) is array (...) of Element'Class (Tag => Element_Type); > (IIRC) > > In Ada we have constrained and unconstrained array types; I call this a "half > constrained" array type so we have names for all of them. Since his language > doesn't have box, I presume an unconstrained array type would be: > > type Unconstrained (Lo : Positive; Hi : Natural) is array (Lo .. Hi) of Component; Rather: type Unconstrained (Lo : Positive; Hi : Natural) is array (Integer range Lo .. Hi) of Component; > while a constrained type would look like an Ada constrained type: > > type Constrained is array (Lo .. Hi) of Component; > > I was wondering how slices would work with this kind of syntax. I would expect a > slice of a half-constrained array to have the fixed lower bound specified in its > type declaration; that would differ from the others. > > In Ada, we deal with slices of constrained array types by having the 1st named > subtype be a constrained subtype of an unconstrained base type; that wouldn't > seem to work here, since it would have a base type with 2 discriminants and a > subtype with only 1. subtype Half_Constrained (Length : Natural) is Unconstrained (1, Length); BTW, starting to modify Ada, one should introduce index types and allow discriminants of any type. Then a range of indices could be just one discriminant rather than two. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de