From: gautier_niouzes@hotmail.com
Subject: Re: Question on bounded / unbounded strings
Date: Tue, 13 Sep 2016 02:35:47 -0700 (PDT)
Date: 2016-09-13T02:35:47-07:00 [thread overview]
Message-ID: <5226e646-3173-4330-b94c-1bd75a09980f@googlegroups.com> (raw)
In-Reply-To: <nnd$12b05e33$1843543e@b46552de0b4781f4>
Hello,
Many languages have types like String (fixed size - rigid but fast) and Unbounded_String (extensible - flexible but slower) and sometimes something inbetween like the bounded strings.
Ada has started with (fixed) String which is a bit difficult for beginners. However, contrary to other languages, "fixed" doesn't mean that the length must be hardcoded in the program. For instance an upper length N can be an "in" parameter which can be any value. Another goodie is that with initialization, the string bounds don't need to be specified. You can have:
s: String:= Get_Line(file);
Also a String as parameter of a subprogram can have any length.
So you'll be done with your program with a few subprograms and the Get_Line function.
(Generally, you can use the functional programming style to work the rigidity of the type String around. You can see an example here
https://sf.net/p/cbsg/code/HEAD/tree/corporate_bullshit.adb
which is done entirely this way...)
The Unbounded_String type is useful rather as a container, like storing database string items into records. The function To_String gets you a String from an Unbounded_String.
_________________________
Gautier's Ada programming
http://gautiersblog.blogspot.com/search/label/Ada
NB: follow the above link for a valid e-mail address
next prev parent reply other threads:[~2016-09-13 9:35 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-13 8:46 Question on bounded / unbounded strings Arie van Wingerden
2016-09-13 9:04 ` Dmitry A. Kazakov
2016-09-22 2:10 ` John Smith
2016-09-22 7:24 ` Dmitry A. Kazakov
2016-09-22 9:01 ` J-P. Rosen
2016-09-22 9:53 ` Dmitry A. Kazakov
2016-09-22 10:58 ` G.B.
2016-09-22 12:05 ` Dmitry A. Kazakov
2016-09-22 14:14 ` G.B.
2016-09-22 17:18 ` Dmitry A. Kazakov
2016-09-22 11:08 ` J-P. Rosen
2016-09-22 12:05 ` Dmitry A. Kazakov
2016-09-22 13:18 ` Maciej Sobczak
2016-09-22 13:52 ` Dmitry A. Kazakov
2016-09-22 14:51 ` Maciej Sobczak
2016-09-22 17:13 ` Dmitry A. Kazakov
2016-09-23 5:50 ` Maciej Sobczak
2016-09-23 6:36 ` Simon Wright
2016-09-23 7:48 ` Dmitry A. Kazakov
2016-09-28 20:55 ` Randy Brukardt
2016-09-23 23:58 ` John Smith
2016-09-24 7:52 ` Dmitry A. Kazakov
2016-09-24 16:25 ` John Smith
2016-09-24 17:44 ` Dmitry A. Kazakov
2016-09-24 18:33 ` John Smith
2016-09-24 18:37 ` John Smith
2016-09-24 18:59 ` John Smith
2016-09-25 8:50 ` Dmitry A. Kazakov
2016-09-25 23:35 ` brbarkstrom
2016-09-26 7:28 ` Dmitry A. Kazakov
2016-09-26 12:39 ` brbarkstrom
2016-09-28 21:09 ` Randy Brukardt
2016-09-30 7:59 ` Björn Lundin
2016-09-13 9:35 ` gautier_niouzes [this message]
2016-09-13 10:41 ` Alejandro R. Mosteo
2016-09-13 17:41 ` Jeffrey R. Carter
2016-09-13 17:59 ` Björn Lundin
2016-09-14 11:23 ` Arie van Wingerden
2016-09-14 12:26 ` Arie van Wingerden
2016-09-14 12:28 ` Arie van Wingerden
2016-09-14 12:57 ` Arie van Wingerden
2016-09-14 19:39 ` Jeffrey R. Carter
2016-09-17 16:35 ` Arie van Wingerden
2016-09-16 14:43 ` Olivier Henley
2016-09-17 16:35 ` Arie van Wingerden
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox