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!news2.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!news-in-01.newsfeed.easynews.com!easynews!core-easynews-01!easynews.com!en-nntp-06.dc1.easynews.com.POSTED!not-for-mail From: Rob Solomon Newsgroups: comp.lang.ada Subject: Re: Why is this not legal Message-ID: <5mq2c5haj6hi5e5gm8b397luua3l5fo79u@4ax.com> References: <03k2c5lvkk6o9ihd9hbhpnobieoupjg9pc@4ax.com> <303d304d-8ff1-4d46-af76-88fafeec7e46@b2g2000yqi.googlegroups.com> X-Newsreader: Forte Agent 4.2/32.1118 MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Complaints-To: abuse@easynews.com Organization: Forte Inc. http://www.forteinc.com/apn/ X-Complaints-Info: Please be sure to forward a copy of ALL headers otherwise we will be unable to process your complaint properly. Date: Mon, 28 Sep 2009 22:06:47 -0400 Xref: g2news2.google.com comp.lang.ada:8527 Date: 2009-09-28T22:06:47-04:00 List-Id: >On Sep 28, 5:11�pm, Rob Solomon wrote: >> I am trying to write some simple string manipulations but am getting >> an error I don't understand. >> >> � type WordEntryType is String(1..MaxLineLength); >> >> This is flagged as not legal. �GNAT 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 That worked. Thanks. I find it confusing when I need a type vs subtype. Modula-2 does not have the subtype concept; it probably could use it though. And your comment that a subtype adds constraints to a type also helps. --rob