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=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!nntp-feed.chiark.greenend.org.uk!ewrotcd!reality.xs3.de!news.jacob-sparre.dk!loke.jacob-sparre.dk!pnx.dk!.POSTED!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Substrings as argument to procedures/functions Date: Wed, 13 Apr 2016 16:29:27 -0500 Organization: JSA Research & Innovation Message-ID: References: <2055a188-fb5f-496a-ab37-b25d81cebe1b@googlegroups.com> NNTP-Posting-Host: rrsoftware.com X-Trace: loke.gir.dk 1460582968 4780 24.196.82.226 (13 Apr 2016 21:29:28 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Wed, 13 Apr 2016 21:29:28 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Response X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 Xref: news.eternal-september.org comp.lang.ada:30102 Date: 2016-04-13T16:29:27-05:00 List-Id: "Jeffrey R. Carter" wrote in message news:nejeuc$57d$1@dont-email.me... > ... And it's possible to declare your own string types (ARM 3.6.3), so you > could declare > > type Str is array (Positive range <>) of Character; > > and do anything with it that you can do with String. This isn't very > useful, but a possibly useful example would be Probably a better example is to remember that the range of Positive is implementation-defined, and that the language only requires the upper bound to be at least 32767. So if you need strings that have potentially more characters than that (to read an entire text file, for instance), and you want the code to be unconditionally portable (to steal someone else's line), you need to declare a type yourself (here, assuming that a million characters are enough): type Big_Natural is range 0 .. 1_000_000; subtype Big_Positive is Big_Natural range 1 .. Big_Natural'Last; type Big_String is array (Big_Positive range <>) of Character; You can do almost anything you can do with a String with a Big_String (and you can convert a Big_String to a String so you can use Put_Line and the like), but the index type is guaranteed to support up to a million characters. Randy.