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=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,1116ece181be1aea X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-10-02 12:15:18 PST Path: archiver1.google.com!news2.google.com!newsfeed.stanford.edu!cyclone.bc.net!sjc70.webusenet.com!news.webusenet.com!elnk-nf2-pas!newsfeed.earthlink.net!wn14feed!worldnet.att.net!204.127.198.203!attbi_feed3!attbi_feed4!attbi.com!rwcrnsc51.ops.asp.att.net.POSTED!not-for-mail Message-ID: <3F7C7943.9040509@comcast.net> From: "Robert I. Eachus" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.0.2) Gecko/20021120 Netscape/7.01 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Is the Writing on the Wall for Ada? References: <1064527575.648809@master.nyc.kbcfp.com> <3F739C1D.4030907@attbi.com> <3F78E850.8010401@comcast.net> <3F797748.3000203@noplace.com> <3F7AC1B4.304@noplace.com> <3F7B0FE2.6010906@comcast.net> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 24.34.139.183 X-Complaints-To: abuse@comcast.net X-Trace: rwcrnsc51.ops.asp.att.net 1065122117 24.34.139.183 (Thu, 02 Oct 2003 19:15:17 GMT) NNTP-Posting-Date: Thu, 02 Oct 2003 19:15:17 GMT Organization: Comcast Online Date: Thu, 02 Oct 2003 19:15:17 GMT Xref: archiver1.google.com comp.lang.ada:129 Date: 2003-10-02T19:15:17+00:00 List-Id: Alexander Kopilovitch wrote: > Robert I. Eachus wrote: >>... >>So I never understand all those complaints about explicitly converting >>to and from Bounded_String (or Unbounded_String). > > (Let's speak about Unbounded_Strings, for clarity). > > There are 2 main reasons for those complaints: > > 1) types Unbounded_String and String appear unrelated, while they are conceptually > related for all natural purposes. (If you want specifically a fixed-size array > of characters which is not assumed to be a textual line in the application then > say "array of Character", and not "String"). > > 2) there is no literals in Ada for Unbounded_Strings which contradicts the > natural concept of a textual line of varying (unlimited) size. > > [From all my experience in (non-corporate) application programming I must say > that while this seemingly tiny and unimportant point remains unresolved, Ada > never will be more popular among programmers than she is now. And if this point > will be resolved with some satifactory way then Ada's popularity will increase > (well, certainly not by magnitude, but quite noticeably) almost immediately. > Well, I'm not sure that it is a good goal to make Ada more popular; therefore > I can admit that preserving status quo here may be actually a proper decision.] If I could wave a magic wand and convince Alexander of the close relationship between String, Unbounded_String, and Bounded_String, I would. Each is an abstract data type representing arbitrary sized chunks of text. The only difference between the three is that for a String, the bounds are a dynamic property of the value. A Bounded_String has a maximum size, and a current size but no bounds, and an Unbounded_String just a current size (and of course the value of the string literal). All of these types are closely related to string literals and character literals so I can say: A: String := "ABC" & 'd'; B: My_Bounded_String := "abc" & 'D' & Null_Bounded_String; C: Unbounded_String := "Abc" & 'd' & Null_Unbounded_String; To_String, To_Bounded_String, and To_Unbounded_String have to do with these attributes. To_String(C) creates a String with 'First = 1 and 'Last = 4. E: String(1000..999); F: String := E & C; Will result in F'First being 1000. So Strings have bounds. Bounded_Strings, Unbounded_Strings, and string literals don't. This is why you can't do indexing or slicing of Unbounded_Strings as such. Either you call a special operation defined in Ada.Strings, or you convert to a String--which has indexes--and index or slice that. Oh, and not all of the potential implicit conversions are defined, just like all the possible catenation operators are not defined, because going any further would tend to make lots of straightforward expressions ambiguous. And if renaming To_Unbounded_String, and To_String as "+" will make you happy, feel free. -- Robert I. Eachus "Quality is the Buddha. Quality is scientific reality. Quality is the goal of Art. It remains to work these concepts into a practical, down-to-earth context, and for this there is nothing more practical or down-to-earth than what I have been talking about all along...the repair of an old motorcycle." -- from Zen and the Art of Motorcycle Maintenance by Robert Pirsig