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=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-09-25 19:31:52 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!headwall.stanford.edu!newshub.sdsu.edu!elnk-nf2-pas!newsfeed.earthlink.net!stamper.news.pas.earthlink.net!stamper.news.atl.earthlink.net!newsread1.news.atl.earthlink.net.POSTED!not-for-mail Sender: mheaney@MHEANEYX200 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> From: Matthew Heaney Message-ID: User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Fri, 26 Sep 2003 02:31:52 GMT NNTP-Posting-Host: 65.110.133.134 X-Complaints-To: abuse@earthlink.net X-Trace: newsread1.news.atl.earthlink.net 1064543512 65.110.133.134 (Thu, 25 Sep 2003 19:31:52 PDT) NNTP-Posting-Date: Thu, 25 Sep 2003 19:31:52 PDT Organization: EarthLink Inc. -- http://www.EarthLink.net Xref: archiver1.google.com comp.lang.ada:42957 Date: 2003-09-26T02:31:52+00:00 List-Id: "Robert I. Eachus" writes: > Hyman Rosen wrote: > > Stephen Leake wrote: > > > >> Ada.Strings.Unbounded. Way better than C++ Strings. > > How? > > For one simple example, an Ada string of any flavor can always contain > all possible character literals and control codes. Hmmm... Are we talking about the same thing? I think the OP was referring to std::basic_string. A std::string in C++ is just the std::basic_string instantiated with type char. One nice thing about C++ std::string is that you have c_str() and data() member functions, which give you a traditional nul-terminated const char* and a non-nul terminated const char*, respectively. This makes it trivial to build up a string using std::string (or its close cousin std::ostringstream), and then to turn around and get the char* array using c_str(), which means it can basically be used everywhere a const char* can. The problem with Ada.Strings.Unbounded is that to do anything useful with it requires a conversion to type String, which is grossly inefficient, not to mention awkward. The ACT people added a Aux child (I think that's the name), which provides a function to return the underlying String_Access. This is how Ada.Strings.Unbounded should have been designed in the first place. The C++ std::string also has a getline procedure to read from stdin directly into a std::string. A similar function should have been provided for Ada.Strings.Unbounded.