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/02 Message-ID: #1/1 X-Deja-AN: 618326656 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> Organization: The World Public Access UNIX, Brookline, MA Newsgroups: comp.lang.ada Date: 2000-05-02T00:00:00+00:00 List-Id: Gautier writes: > But would you agree that your Variable_String [http://pro.wanadoo.fr/adalog/compo2.htm] > is missing as Ada.Variable_String ? 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. Note that you can't tell by looking at the code (locally) whether or not assignment is safe. JPR's approach is fine, but the RM's approach is safer: instead of just telling you "assignment doesn't work", it uses the type system to prevent assignment in the cases that won't work. 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. This thread sure is wandering! I mean, it's hard to see how one can explain the popularity of C or C++ by the fact that Turbo Pascal has better strings than Ada (in one respect). That was what was being discussed, wasn't it? ;-) In fact, C-style strings are quite primitive, and quite painful to work with, even compared to Ada 83 strings. - Bob