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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,f868292008c639ce X-Google-Attributes: gid103376,public From: "Pete" Subject: Re: C vs. Ada - strings Date: 2000/05/18 Message-ID: <1fIU4.4668$Rx3.250161@typhoon.nyroc.rr.com>#1/1 X-Deja-AN: 624799772 References: <390F0D93.F835FAD9@ftw.rsc.raytheon.com> <8en5o9$ihe$1@nnrp1.deja.com> <8eonos$e70$1@wanadoo.fr> X-Priority: 3 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6600 X-Complaints-To: abuse@twcny.rr.com X-Trace: typhoon.nyroc.rr.com 958615613 24.164.184.63 (Wed, 17 May 2000 22:06:53 EDT) Organization: Time Warner Road Runner - Syracuse NY X-MSMail-Priority: Normal NNTP-Posting-Date: Wed, 17 May 2000 22:06:53 EDT Newsgroups: comp.lang.ada Date: 2000-05-18T00:00:00+00:00 List-Id: really both versions aren't that great. java strings are much better. if s and t are strings of different lengths, suppose s = "junk"; t = "garbage". it should make sense to write s = s + t; and your result is "junkgarbage" as java does. you should definitely not have to make sure that s is big enough to hold a string of length s and t or call any function to reallocate memory. it should happen automatically, under the covers. the most annoying thing in ada is the output messages. if you write Positive'Image("5"). You get back " 5", with a space for an optional - sign, even though it is a positive number! or even worse, instantiate a generic package to handle printing of numbers, instead of System.out.println("This is junk " + i); (where i is a numeric type). - pete "Keith Thompson" wrote in message news:yec1z3jkq9z.fsf@king.cts.com... > "Pascal Obry" writes: > [...] > > But where did you see a C string ? In C you have a pointer to a memory > > space terminated by 'nul' ! > > > > This is not a string to me. And because C does not have strings, there is > > no operator on them you have to use strcmp, strcpy, strcat, strncmp... > > > > Is that what a string is for C programmers :) > > Serious answer: yes. > > The C90 standard's definition of the term "string" is > > A string is a contiguous sequence of characters terminated by and > including the first null character. A "pointer to" a string is a > pointer to its initial (lowest addressed) character. The "length" > of a string is the number of characters preceding the null > character and its "value" is the sequence of the values of the > contained characters, in order. > > As for the lack of built-in operators, it's certainly nice to have "=", > ":=", "<", "&", and so forth, but the fact that these are implemented > as function calls in C isn't really that big a deal. (In other areas, > C is criticized for being too terse.) > > This isn't to say that C's string handling isn't flawed. Once of > the biggest problems is that, though a function can return a pointer > to a (variable-length) string, there's no standard way to manage the > associated memory. > > -- > Keith Thompson (The_Other_Keith) kst@cts.com > San Diego Supercomputer Center <*> > Welcome to the last year of the 20th century.