comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Substrings as argument to procedures/functions
Date: Wed, 13 Apr 2016 16:29:27 -0500
Date: 2016-04-13T16:29:27-05:00	[thread overview]
Message-ID: <nemdnn$4lc$1@loke.gir.dk> (raw)
In-Reply-To: nejeuc$57d$1@dont-email.me

"Jeffrey R. Carter" <spam.jrcarter.not@spam.not.acm.org> 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.




  reply	other threads:[~2016-04-13 21:29 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-12  8:25 Substrings as argument to procedures/functions reinkor
2016-04-12  9:01 ` Dmitry A. Kazakov
2016-04-12 16:55   ` reinkor
2016-04-12 18:37     ` Dmitry A. Kazakov
2016-04-13  4:44       ` reinkor
2016-04-13  7:19         ` Dmitry A. Kazakov
2016-04-13 10:16         ` Brian Drummond
2016-04-13 11:43           ` reinkor
2016-04-13 11:54             ` Pascal Obry
2016-04-13 12:30               ` Mart van de Wege
2016-04-13 12:47                 ` Egil H H
2016-04-13 13:19                   ` Mart van de Wege
2016-04-13 16:57                 ` Jeffrey R. Carter
2016-04-12 18:17 ` Robert A Duff
2016-04-12 18:34 ` Jeffrey R. Carter
2016-04-13 21:29   ` Randy Brukardt [this message]
2016-04-25 15:33     ` rieachus
2016-04-25 22:07       ` Randy Brukardt
2016-04-26  6:12         ` Georg Bauhaus
2016-04-26 18:41           ` Randy Brukardt
2016-04-13 11:22 ` G.B.
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox