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-Thread: a07f3367d7,4496c60dc079a16a X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!postnews.google.com!b2g2000yqi.googlegroups.com!not-for-mail From: Adam Beneschan Newsgroups: comp.lang.ada Subject: Re: Why is this not legal Date: Mon, 28 Sep 2009 17:23:49 -0700 (PDT) Organization: http://groups.google.com Message-ID: <303d304d-8ff1-4d46-af76-88fafeec7e46@b2g2000yqi.googlegroups.com> References: <03k2c5lvkk6o9ihd9hbhpnobieoupjg9pc@4ax.com> NNTP-Posting-Host: 66.126.103.122 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1254183829 22668 127.0.0.1 (29 Sep 2009 00:23:49 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 29 Sep 2009 00:23:49 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: b2g2000yqi.googlegroups.com; posting-host=66.126.103.122; posting-account=duW0ogkAAABjRdnxgLGXDfna0Gc6XqmQ User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; WOW64; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.5.21022; .NET CLR 3.5.30729; .NET CLR 3.0.30618),gzip(gfe),gzip(gfe) Xref: g2news2.google.com comp.lang.ada:8526 Date: 2009-09-28T17:23:49-07:00 List-Id: On Sep 28, 5:11=A0pm, Rob Solomon wrote: > I am trying to write some simple string manipulations but am getting > an error I don't understand. > > =A0 type WordEntryType is String(1..MaxLineLength); > > This is flagged as not legal. =A0GNAT want it to read > IS NEW String > > But that means the type is not a standard string. > > What am I missing? The three letters "sub" in front of the keyword "type". TYPE declarations always create a new type. SUBTYPE declarations will declare an identifier that refers to the same *type*, but puts additional constraints on it. But if you use a SUBTYPE declaration, and you declare something of type X : WordEntryType; then X's *type* will be STRING and you can pass it to procedures that require a STRING parameter. If this is still confusing to you, then I'd say you need to go back and read some more about Ada's type system. This is an important feature of Ada that distinguishes it from C, Pascal, and possibly Modula (I don't know Modula well enough to say), and any decent introductory book on Ada should have a good exposition of this concept. -- Adam