comp.lang.ada
 help / color / mirror / Atom feed
From: "Pete" <tyrone@nowhere.org>
Subject: Re: C vs. Ada - strings
Date: 2000/05/18
Date: 2000-05-18T00:00:00+00:00	[thread overview]
Message-ID: <1fIU4.4668$Rx3.250161@typhoon.nyroc.rr.com> (raw)
In-Reply-To: yec1z3jkq9z.fsf@king.cts.com

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" <kst@cts.com> wrote in message
news:yec1z3jkq9z.fsf@king.cts.com...
> "Pascal Obry" <p.obry@wanadoo.fr> 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  <http://www.ghoti.net/~kst>
> San Diego Supercomputer Center           <*>  <http://www.sdsc.edu/~kst>
> Welcome to the last year of the 20th century.






  parent reply	other threads:[~2000-05-18  0:00 UTC|newest]

Thread overview: 74+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-05-02  0:00 C vs. Ada - strings Wes Groleau
2000-05-02  0:00 ` Robert A Duff
2000-05-03  0:00   ` Tarjei T. Jensen
2000-05-03  0:00     ` Charles Hixson
2000-05-04  0:00     ` Robert Dewar
2000-05-04  0:00       ` Charles Hixson
2000-05-06  0:00       ` Tarjei Tj�stheim Jensen
2000-05-03  0:00   ` Wes Groleau
2000-05-03  0:00     ` Tarjei Tj�stheim Jensen
2000-05-03  0:00       ` Ted Dennison
2000-05-04  0:00   ` Robert Dewar
2000-05-04  0:00     ` Robert A Duff
2000-05-04  0:00       ` Robert Dewar
2000-05-05  0:00         ` Florian Weimer
2000-05-05  0:00           ` Pascal Obry
2000-05-05  0:00             ` Hyman Rosen
2000-05-06  0:00           ` Tarjei Tj�stheim Jensen
2000-05-06  0:00             ` Florian Weimer
2000-05-07  0:00               ` Robert Dewar
2000-05-09  0:00                 ` Florian Weimer
2000-05-04  0:00     ` Hyman Rosen
2000-05-04  0:00       ` Jon S Anthony
2000-05-04  0:00       ` Robert Dewar
2000-05-02  0:00 ` Ted Dennison
2000-05-03  0:00   ` Pascal Obry
2000-05-03  0:00     ` Keith Thompson
2000-05-04  0:00       ` Wes Groleau
2000-05-18  0:00       ` Pete [this message]
2000-05-18  0:00         ` dale
2000-05-18  0:00           ` Robert A Duff
2000-05-19  0:00             ` dale
2000-05-21  0:00             ` Robert Dewar
2000-05-22  0:00               ` Robert A Duff
2000-05-22  0:00                 ` Keith Thompson
2000-05-24  0:00                 ` 'img Peter Hermann
2000-05-24  0:00                   ` 'img Robert Dewar
2000-05-24  0:00                     ` 'img Ted Dennison
2000-05-25  0:00                       ` 'img Peter Hermann
2000-05-25  0:00                         ` 'img Keith Thompson
2000-05-25  0:00                           ` 'img Ted Dennison
2000-05-26  0:00                         ` 'img dmitry
2000-05-26  0:00                           ` 'img Robert Dewar
2000-05-26  0:00                           ` 'img Brian Rogoff
2000-05-26  0:00                             ` 'img Robert Dewar
2000-05-25  0:00                       ` 'img Robert Dewar
2000-05-19  0:00         ` C vs. Ada - strings Geoff Bull
2000-05-19  0:00           ` mike
2000-05-21  0:00           ` Robert Dewar
2000-06-03  0:00           ` Pete
2000-06-03  0:00             ` Ken Garlington
2000-06-03  0:00               ` Ted Dennison
2000-06-04  0:00                 ` Ken Garlington
2000-06-04  0:00                 ` Dale Stanbrough
2000-06-03  0:00             ` Java vs. Ada - strings (was: C vs. Ada - strings) Ted Dennison
2000-06-04  0:00               ` Pete
2000-06-04  0:00                 ` Jean-Pierre Rosen
2000-06-04  0:00                   ` Pete
2000-06-05  0:00                     ` Jean-Pierre Rosen
2000-06-05  0:00                 ` Ted Dennison
2000-06-05  0:00                   ` Marin D. Condic
2000-06-05  0:00                     ` David Botton
2000-06-05  0:00                       ` Marin D. Condic
2000-06-06  0:00                     ` Robert A Duff
2000-06-06  0:00                   ` Ken Garlington
2000-06-06  0:00                     ` Marin D. Condic
2000-06-04  0:00               ` Robert I. Eachus
2000-05-03  0:00   ` C vs. Ada - strings Wes Groleau
2000-05-03  0:00     ` Ted Dennison
2000-05-04  0:00   ` Ole-Hjalmar Kristensen
2000-05-04  0:00     ` Gautier
2000-05-02  0:00 ` Larry Kilgallen
2000-05-05  0:00 ` Florian Weimer
2000-05-05  0:00   ` Ted Dennison
2000-05-05  0:00   ` Robert Dewar
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox