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,1cf653444208df72 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-11-12 18:12:03 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!cyclone.bc.net!sjcppf01.usenetserver.com!usenetserver.com!newsfeed1.cidera.com!Cidera!cyclone.nyroc.rr.com!news-east.rr.com!wn2feed!worldnet.att.net!135.173.83.71!wnfilter1!worldnet-localpost!bgtnsc05-news.ops.worldnet.att.net.POSTED!not-for-mail From: "David Thompson" Newsgroups: comp.lang.ada References: <9pgr68$7pu1@news.cis.okstate.edu> <3bbd6287.346843109@news.cis.dfn.de> <3bcbfda2.7486093@news.cis.dfn.de> Subject: Re: ada vs. cpp X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.00.2615.200 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2615.200 Message-ID: Date: Tue, 13 Nov 2001 02:12:01 GMT NNTP-Posting-Host: 12.89.171.190 X-Complaints-To: abuse@worldnet.att.net X-Trace: bgtnsc05-news.ops.worldnet.att.net 1005617521 12.89.171.190 (Tue, 13 Nov 2001 02:12:01 GMT) NNTP-Posting-Date: Tue, 13 Nov 2001 02:12:01 GMT Organization: AT&T Worldnet Xref: archiver1.google.com comp.lang.ada:16390 Date: 2001-11-13T02:12:01+00:00 List-Id: Dmitry Kazakov wrote : > On Tue, 16 Oct 2001 04:52:02 GMT, "David Thompson" > wrote: ... > >> Sorry, but Ada is one of rare languages which are able to manipulate > >> strings allocated on the stack. IMO strings are indeed one of Ada > >> strengths, especially if you need an efficient parsing code. ... > > [..] Strings in COBOL, PL/1, FORTRANs [,Pascal] etc ... > No, said that Ada has excellent strings. It is true that many > languages have strings. Even FORTRAN IV arrays of LOGICAL*1 could be > counted as strings (:-)). However, to have an excellent string support > one should fulfil some requrements, which include IMO: > I think the fair measure is whether strings are supported to the same or an equivalent extent as other data types in the same language. (Equivalence is of course a judgement call.) > 1. There are stack allocated strings Yes for all of the above. > 2. There are in, out, inout parameters and returns of the string type Modern Fortran yes. Older FORTRAN, COBOL, and PL/1 have all parameters by reference with no modes (for all data types). Pascal distinguishes by-value and by-reference, and ExtdPascal adds nonmodifiable, but not out vs inout (again for all types). Fortran PL/1 and Pascal do support string return values; COBOL does not support return values of any data type. > 3. The string bounds are not a part of the type I think you have to distinguish between parameters and actual variables/objects. Even in Ada except for Unbounded an actual string object has a type constrained by (max) size, but for Bounded the current (valid) contents may be <= size; the same is true for PL/1 and ExtdPascal. For COBOL, Fortran, and basicPascal a string object is a fixed size (although COBOL can have a DEPENDING array). Fortran and basicPascal (level 1) in addition to PL/1 do support _parameters_ with size determined at runtime by the actual argument. (Most?) COBOL implementations (like C) actually work for any size actual argument but this is not a defined feature of the language. In all except Pascal a string lower bound is always 1, only the upper bound varies. (PL/1 supports other lower bounds for _arrays_ but strings are not arrays there.) > 4. Bounds can be obtained from any string object (Or upper bound, where the lower bound is fixed.) Again I think there are several cases: for actual objects (except Ada Unbounded, which is not stack allocated at least not in general) the size is determined either explicitly or implicitly in the declaration, so this is "only" a convenience (though sometimes a useful one). For parameters whose (argument) size is known only at runtime, Fortran, PL/1, and Pascal yes. For Bounded strings whose current contents are distinct from the object size, the current bound is available in PL/1 and ExtdPascal, the only ones that have this type. > 5. There are constrained string subtypes Yes, as above. > 6. String slices Yes except basic Pascal. In COBOL and Fortran using an array-like syntax, in PL/1 and ExtdPascal using a function-like syntax but usable as an lvalue. ... > Maybe. However, I would like to see an example of such new ground > breaking. [by Ada in string handling] You mean you would like to find something that is in Ada already that was/is not in other languages? I don't see anything major. Or you want to propose adding new features to Ada that other languages don't have? That's a different question. I don't see anything I consider vitally needed that I would push for, but I can imagine many things I wouldn't mind having. > ... Some people here have argued that C++ has strings because > one can develop them. Very well, to follow this logic I expect that > there is something extr-r-r-emely important and new for strings that > cannot be [efficiently] implemented in Ada 95. And? > I for one have argued that one can easily implement in C++ the equivalent of Strings.Fixed and Bounded, although this is not as convenient (for integration, reuse, etc.) as having them standard. It already has the equivalent of Unbounded. I don't understand the rest of your statement. ... > >As previously noted C++ std::string is closely comparable > >to Ada.Strings.Unbounded (and dynamically allocated). > > As I have pointed in other post I disagree with this logic. What can > be expressed in the language terms is *not* a part of the language. > Then Annex A is not part of Ada? Nor loops because they can be constructed from goto? I think the the language definition defines the language. One could argue that early versions of C++ were deficient in this respect, but not now; std::string is required to be present (and provide the same functionality) on all implementations. > Yes, in C++ one may have what bounded or unbounded Ada strings are. > Then there are ready to use string implementations like STL or MFC. > But C++ have nothing comparable with the type String in Ada. > MFC is a very different matter. It is NOT standard. Neither is STL as such, although it has a _big_ overlap with the C++ standard library. -- - David.Thompson 1 now at worldnet.att.net