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,54c513170bafd693 X-Google-Attributes: gid103376,public From: Robert A Duff Subject: Re: Desirability of C++ Date: 2000/05/03 Message-ID: #1/1 X-Deja-AN: 618713575 Sender: bobduff@world.std.com (Robert A Duff) References: <390DEC7F.9429C82C@online.no><390E2A20.B647D0D6@maths.unine.ch> <8em8mb$evd$1@wanadoo.fr><390EEF24.BD36AA24@maths.unine.ch> <8eonat$sqj3@ftp.kvaerner.com> Organization: The World Public Access UNIX, Brookline, MA Newsgroups: comp.lang.ada Date: 2000-05-03T00:00:00+00:00 List-Id: "Tarjei T. Jensen" writes: > Robert A Duff wrote > >The designer of Ada.Strings.Unbounded (Ben Brosgol) considered doing it > >as in the above-mentioned package. The reason not to do it that way is > >documented in the AARM -- assignment statements don't work properly. > >That is, if you assign a 5-character string (whose max length is 80) to > >a string variable whose max is 120, you will get a Constraint_Error, > >even though 5 characters fit nicely in 120. JPR points this out in the > >documentation for his package, and he provides a procedure for copying > >strings, which should be used instead of assignment. > > A more natural conclusion would be that there was a language problem. That *was* the conclusion. >...In order > to fix it one would either have to make the compiler aware of strings, make it > possible to tell the compiler about what controls the size of a variable sized > object like a counted string or make it possible to override the assignment > operator. All of those changes were considered too big. > It would be convenient to be able to tell the compiler how to access the > character array in string types other than the ordinary ada string. It would > save a lot of copying. And it should be quite safe since routines that use the > ordinary string types cannot change the length of the string. > > >Apparently, Turbo Pascal actually makes assignment work, which is > >obviously preferable to either of the above Ada alternatives. On the > >other hand, there are lots of *other* things wrong with the Turbo Pascal > >solution, which have been pointed out in this thread. > > I think it was the ucsd-pascal people who first got it right. They got some things right, and some things wrong. For example, the limit of 255 characters is pretty annoying -- even in the bad old days of smaller memories. > C has only one string type. C doesn't even have a character type, much less a string type! It has an integer type called char, it has pointers to [arrays of] those, it has character literal and string literal notations, it has a nul-termination convention, and a few library routines. But it doesn't have the most basic things you want, such as carrying the length with the string, comparison operators, assignment operator. >... It works reasonably well. Probably the most > important "feature" is that everything is by reference, so there is no problems > with strings of different sizes, etc. - Bob