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: a07f3367d7,ac4955b8006bd13c X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII Received: by 10.68.201.132 with SMTP id ka4mr9871691pbc.8.1338797134345; Mon, 04 Jun 2012 01:05:34 -0700 (PDT) Path: l9ni18401pbj.0!nntp.google.com!news1.google.com!feed-C.news.volia.net!volia.net!news2.volia.net!feed-A.news.volia.net!news.ecp.fr!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Q: type ... is new String Date: Mon, 4 Jun 2012 10:03:12 +0200 Organization: cbb software GmbH Message-ID: References: <336f4e4b-16da-4fa8-9b7a-7e2dd3a48018@w24g2000vby.googlegroups.com> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: FbOMkhMtVLVmu7IwBnt1tw.user.speranza.aioe.org Mime-Version: 1.0 X-Complaints-To: abuse@aioe.org User-Agent: 40tude_Dialog/2.0.15.1 X-Notice: Filtered by postfilter v. 0.8.2 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit Date: 2012-06-04T10:03:12+02:00 List-Id: On Mon, 04 Jun 2012 09:48:07 +0200, Yannick Duch�ne (Hibou57) wrote: > Le Mon, 04 Jun 2012 08:30:14 +0200, J-P. Rosen a �crit: > >> Le 04/06/2012 07:58, Yannick Duch�ne (Hibou57) a �crit : >>> Minimum_Length : constant := ; >>> Maximum_Length : constant := ; >>> >>> subtype Index_Type is Natural range Minimum_Length .. Maximum_Length; >>> >>> type Path_Type is new String (Index_Type); >>> -- Unfortunately, this freeze the lower and upper bound, and the >>> -- declaration below fails. >>> >>> XYZ_Location : Path_Type := "..................."; -- Will fail. >> Why not: >> type Path_Type is array (Index_Type range <>) of Character; >> >> ? >> Reminder: There is nothing special to type String, you'll still have >> literals etc. > > Good idea. I did not consider this one, may be due to the natural tendency > of deriving from an already existing type with similar meaning. It is not natural, it is sloppy. You (1) derive when the result type shall be in the same class [with class-wide objects]. You (2) clone or use other means to create an independent type when there shall be no class [no class-wide objects]. It is a conscious design choice between 1 and 2. > While I'm OK with this idea and feel it good, I would not apply it, > because I would prefer to derive from String. Ada lacks a way to narrow > the allowed range of a derived array type. subtype Punch_Card is String (1..80); -- ? -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de