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,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.107.41.81 with SMTP id p78mr25045114iop.13.1461598399221; Mon, 25 Apr 2016 08:33:19 -0700 (PDT) X-Received: by 10.182.74.8 with SMTP id p8mr264908obv.6.1461598399193; Mon, 25 Apr 2016 08:33:19 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!news.glorb.com!sq19no512144igc.0!news-out.google.com!uv8ni325igb.0!nntp.google.com!sq19no512134igc.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Mon, 25 Apr 2016 08:33:18 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=2601:191:8202:8510:5985:2c17:9409:aa9c; posting-account=fdRd8woAAADTIlxCu9FgvDrUK4wPzvy3 NNTP-Posting-Host: 2601:191:8202:8510:5985:2c17:9409:aa9c References: <2055a188-fb5f-496a-ab37-b25d81cebe1b@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <518c7059-14c6-4344-a251-129cca2621af@googlegroups.com> Subject: Re: Substrings as argument to procedures/functions From: rieachus@comcast.net Injection-Date: Mon, 25 Apr 2016 15:33:19 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Xref: news.eternal-september.org comp.lang.ada:30281 Date: 2016-04-25T08:33:18-07:00 List-Id: On Wednesday, April 13, 2016 at 5:29:29 PM UTC-4, Randy Brukardt wrote: > Probably a better example is to remember that the range of Positive is=20 > implementation-defined, and that the language only requires the upper bou= nd=20 > to be at least 32767. So if you need strings that have potentially more= =20 > characters than that (to read an entire text file, for instance), and you= =20 > want the code to be unconditionally portable (to steal someone else's lin= e),=20 > you need to declare a type yourself (here, assuming that a million=20 > characters are enough)... Is it time to "fix" this? Or are there still Ada compilers around that use= 16-bit String indexes by default? I remember when (in the early days of Ad= a83) the question of whether String should use 16 or 32 bit indexes was a m= ajor implementation decision. Today, compilers that support hardware index= es shorter than 32-bits are probably mapping to some hardware defined offse= t field in instructions. Using such indexes when the subtype allows is obvi= ously an optimization worth supporting. But in Ada defining "subtype Short= _String is String range (1..32767);" or whatever allows using such a hardwa= re type if available. But there is no need to make Short_String a type. Yes, programs may have records with character string fields limited such th= at the index can fit into a 16-bit field in the record. But I can't imagin= e doing that without an explicit layout for the record or at least a size f= or the index field. Back to the original topic here, you want/need sliding = to work such that type Rec is Name_Length : Integer range 0..32_767;=20 Name: String; end; for Rec use ... ... Name_Length :=3D Param'Length; Name(1..Name_Length) :=3D Param; works as expected.