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=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,c406e0c4a6eb74ed X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews2.google.com!not-for-mail From: kevin.cline@gmail.com (Kevin Cline) Newsgroups: comp.lang.ada Subject: Re: ADA Popularity Discussion Request Date: 14 Sep 2004 09:28:23 -0700 Organization: http://groups.google.com Message-ID: References: <49dc98cf.0408110556.18ae7df@posting.google.com> <413e2fbd$0$30586$626a14ce@news.free.fr> NNTP-Posting-Host: 198.23.26.253 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1095179304 9064 127.0.0.1 (14 Sep 2004 16:28:24 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 14 Sep 2004 16:28:24 +0000 (UTC) Xref: g2news1.google.com comp.lang.ada:3725 Date: 2004-09-14T09:28:23-07:00 List-Id: Pascal Obry wrote in message news:... > kevin.cline@gmail.com (Kevin Cline) writes: > > > > Does the C++ standard directly address the behavior of handwritten > > > bounded numbers? How many lines of template code will it take > > > to get the effect of > > > > > > type A is array(Some_Index_Type) of Foo;? > > > > I don't know. It could be done in C++ if Some_Index_Type had the > > right properties. But as a practical matter, no one seems to care, at > > least no one in the C++ community. I very rarely have any need or use > > for a statically sized array. > > That's why working with strings in C/C++ is a nightmare! strcpy/strcat,++,-- > and so on... Look at some real world C/C++ code handling strings ! > > For memory, a string in Ada is: > > type String is array (Positive range <>) of Character; > > And you can do something like: > > function Some_Value return String is > begin > return "..."; > end Some_Value; > > S1 : constant String := "a long string"; > S2 : constant String := "this is definitly " & S1 & Some_Value; > > S3 : constant String := S1 (S1'First + 2 .. S1'First + 5); > > Pascal. Yes, but that can get really inefficient when you need to build up a string from multiple parts and don't know the final length. You keep returning intermediate strings by value and what should be O(n) code becomes O(n^2). I suppose one could first collect all the parts and then join them, but that's a convoluted way to write string handling code. C++: std::string some_value() { return "..."; } std::string s1("a long string"); std::string s2("this is definitely " + s1 + some_value()); std::string s3(s1.substring(2, 3));