comp.lang.ada
 help / color / mirror / Atom feed
From: Robert A Duff <bobduff@world.std.com>
Subject: Re: Desirability of C++
Date: 2000/05/03
Date: 2000-05-03T00:00:00+00:00	[thread overview]
Message-ID: <wccaei7lm9z.fsf@world.std.com> (raw)
In-Reply-To: 390FBAD0.7CECA91A@earthlink.net

"Robert I. Eachus" <rieachus@earthlink.net> writes:

> Robert A Duff wrote:
>    
> > ...Apparently, Turbo Pascal actually makes assignment work, which is
> > obviously preferable to either of the above Ada alternatives.
> 
>     I guess I don't see this.  In Ada, you have several choices: String,
> Bounded_String, and Unbounded_String.  Each is appropriate in different
> places, and, yes it can be painful if you are forced--by ignorance or
> management--to use the wrong abstraction for the job at hand.

I was only talking about cases where bounded strings *are* appropriate.
In that case, a comparison can be made between the Ada and Turbo Pascal
support.  (Several dialects of Pascal had similar features, actually.)

>     But when an instance of Bounded_String is the appropriate choice, it
> has always been my experience that you WANT the compiler to reject
> assignments between objects with different maximum sizes.

I don't see why.  It makes perfect sense to assign a max-5 string into a
max-10 string, and it can't fail at run time.  I could understand
wanting to reject assignments from max-10 to max-5, because otherwise
that might fail at run time.

>...  That is
> almost always either a bug or a situation that code to handle the
> potential mismatch.  If you really get upset about explicit conversions,
> then instantiate Bounded_String once, with the maximum of all the
> maximum sizes.

Then you waste memory on the strings that could have been small.
If you think different max sizes are useful at all, then surely
you will want to make different choices in different cases.

>     The other thing to note is that having multiple instances of
> Bounded_Strings in your program cannot result in code bloat.

Surely you don't mean "cannot".  If you write 16 instantiations of
Ada.Strings.Bounded in your program, you will get 16 copies of the code,
on most compilers.  Perhaps you mean that a clever compiler could share
the code?

>...Hint: 
> Write a program that reads a number from Current_Input, then calls a
> subroutine that recursively calls itself and on each call, instantiates
> Ada.Strings.Bounded for a different maximum length:
> 
>      function Recur(N: Natural) return String is
>         package BS is new Ada.Strings.Bounded(N);
>      begin
>         if N > 0
>         then
>           return Recur(N-1) & 'X';
>         else return "";
>         end if;
>         return end Recur;
>      -- put in some code that exercises the instance if you want... 
> 
>   How many copies of the code for Ada.Strings.Bounded are there in your
> executable? Can you call Recur with a larger value of N?

One.  But it's not terribly useful, being inside a recursive function
where I can't get at it.

- Bob




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

Thread overview: 176+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-02-04  0:00 where can we get a job with ada HollymaN
2000-02-03  0:00 ` David Kristola
2000-02-04  0:00   ` EKoerber
2000-02-04  0:00     ` Ted Dennison
2000-02-04  0:00       ` Brian Rogoff
2000-02-05  0:00         ` David Kristola
2000-02-06  0:00           ` Simon Brady
2000-02-07  0:00             ` Gareth
2000-02-07  0:00               ` Ted Dennison
2000-02-07  0:00               ` Simon Brady
2000-02-07  0:00               ` Kent Paul Dolan
2000-02-07  0:00                 ` Gareth
2000-02-08  0:00                   ` Kent Paul Dolan
2000-02-11  0:00                 ` where can we ... [off topic] Nick Roberts
2000-02-12  0:00               ` where can we get a job with ada Jeff Carter
2000-02-07  0:00             ` Ted Dennison
2000-02-28  0:00             ` Florian Weimer
2000-02-29  0:00               ` Ted Dennison
2000-03-01  0:00               ` Wes Groleau
2000-03-04  0:00               ` Robert B. Love 
2000-03-05  0:00                 ` Ted Dennison
2000-03-05  0:00                 ` Ada on International Space Station (Re: where can we get a job with ada) Vladimir Olensky
2000-03-08  0:00                   ` Robert B. Love 
2000-03-08  0:00                     ` Vladimir Olensky
2000-03-08  0:00                     ` Jean St-Pierre
2000-04-03  0:00                   ` Andrew Thomas Wilson
2000-04-12  0:00                     ` David Hoffman
2000-04-13  0:00                       ` Robert B. Love 
2000-04-14  0:00                         ` Desirability of C++ (was Re: Ada on International Space Station (Re: where can we get a job with ada)) David Kristola
2000-04-14  0:00                           ` Wes Groleau
2000-04-14  0:00                             ` Desirability of C++ Stanley R. Allen
2000-04-14  0:00                               ` Marin D. Condic
2000-04-15  0:00                                 ` Tarjei T. Jensen
2000-04-15  0:00                                   ` Marin D. Condic
2000-04-15  0:00                                     ` Tarjei T. Jensen
2000-04-17  0:00                                   ` Alfred Hilscher
2000-04-17  0:00                                     ` Gautier
2000-04-18  0:00                                       ` Pascal Obry
2000-04-18  0:00                                       ` Tarjei T. Jensen
2000-04-18  0:00                                         ` Gautier
2000-04-28  0:00                                         ` Richard D Riehle
2000-05-02  0:00                                           ` Tarjei T. Jensen
2000-04-23  0:00                                       ` David Kristola
2000-04-18  0:00                                     ` Tarjei T. Jensen
2000-04-17  0:00                                 ` Alfred Hilscher
2000-04-17  0:00                                   ` Marin D. Condic
2000-04-17  0:00                                     ` Gary Scott
2000-04-28  0:00                               ` Richard D Riehle
2000-04-30  0:00                                 ` Robert B. Love 
2000-05-01  0:00                                   ` Richard D Riehle
2000-05-01  0:00                                     ` Tarjei Tj�stheim Jensen
2000-05-01  0:00                                     ` E. Robert Tisdale
2000-04-30  0:00                                       ` Keith Thompson
2000-05-01  0:00                                         ` E. Robert Tisdale
2000-05-01  0:00                                           ` Keith Thompson
2000-05-01  0:00                                       ` Gautier
2000-05-01  0:00                                         ` E. Robert Tisdale
2000-05-01  0:00                                           ` Pat Rogers
2000-05-01  0:00                                             ` David Starner
2000-05-01  0:00                                               ` David Starner
2000-05-01  0:00                                               ` Pat Rogers
2000-05-01  0:00                                                 ` Ted Dennison
2000-05-01  0:00                                                   ` E. Robert Tisdale
2000-05-01  0:00                                                     ` Gautier
2000-05-01  0:00                                                     ` Pat Rogers
2000-05-01  0:00                                               ` Florian Weimer
2000-05-01  0:00                                                 ` tmoran
2000-05-01  0:00                                                 ` Lionel Draghi
2000-05-02  0:00                                                   ` Florian Weimer
2000-05-01  0:00                                                 ` David Starner
2000-05-01  0:00                                                 ` Ted Dennison
2000-05-01  0:00                                                   ` Tarjei Tj�stheim Jensen
2000-05-01  0:00                                                     ` Ted Dennison
2000-05-02  0:00                                                       ` Florian Weimer
2000-05-02  0:00                                                       ` Preben Randhol
2000-05-02  0:00                                                   ` Application in Ada (was Desirability of C++) Jean-Pierre Rosen
2000-05-02  0:00                                                     ` Ted Dennison
2000-05-02  0:00                                                       ` Jean-Pierre Rosen
2000-05-03  0:00                                                       ` Tarjei Tj�stheim Jensen
2000-05-03  0:00                                                         ` Ted Dennison
2000-05-01  0:00                                             ` Desirability of C++ E. Robert Tisdale
2000-05-01  0:00                                               ` Pat Rogers
2000-05-01  0:00                                                 ` Michael P. Walsh
2000-05-01  0:00                                                   ` Pat Rogers
2000-05-01  0:00                                                     ` E. Robert Tisdale
2000-05-02  0:00                                                       ` Bill Greene
2000-05-01  0:00                                         ` Hyman Rosen
2000-05-01  0:00                                           ` Tarjei Tj�stheim Jensen
2000-05-01  0:00                                             ` tmoran
2000-05-02  0:00                                               ` Al Christians
2000-05-02  0:00                                               ` Gautier
2000-05-02  0:00                                                 ` Jean-Pierre Rosen
2000-05-02  0:00                                                   ` Gautier
2000-05-02  0:00                                                     ` Jean-Pierre Rosen
2000-05-03  0:00                                                       ` Robert A Duff
2000-05-03  0:00                                                         ` Jean-Pierre Rosen
2000-05-03  0:00                                                       ` Marin D. Condic
2000-05-03  0:00                                                         ` Jean-Pierre Rosen
2000-05-03  0:00                                                           ` Wes Groleau
2000-05-04  0:00                                                         ` Robert I. Eachus
2000-05-05  0:00                                                           ` Marin D. Condic
2000-05-02  0:00                                                     ` Robert A Duff
2000-05-03  0:00                                                       ` Robert I. Eachus
2000-05-03  0:00                                                         ` Robert A Duff [this message]
2000-05-04  0:00                                                           ` Robert I. Eachus
2000-05-03  0:00                                                       ` Tarjei T. Jensen
2000-05-03  0:00                                                         ` Robert A Duff
2000-05-03  0:00                                                           ` Delphi Strings (was Re: Desirability of C++) Ray Blaak
2000-05-03  0:00                                                         ` Desirability of C++ Pascal Obry
2000-05-03  0:00                                                           ` Paul Graham
2000-05-03  0:00                                                             ` Pascal Obry
2000-05-03  0:00                                                               ` Paul Graham
2000-05-03  0:00                                                                 ` Robert A Duff
2000-05-04  0:00                                                               ` Ole-Hjalmar Kristensen
2000-05-04  0:00                                                                 ` Preben Randhol
2000-05-04  0:00                                                                   ` Ole-Hjalmar Kristensen
2000-05-04  0:00                                                                     ` Preben Randhol
2000-05-04  0:00                                                                 ` Pascal Obry
2000-05-05  0:00                                                             ` Gautier
2000-05-04  0:00                                                           ` Ole-Hjalmar Kristensen
2000-05-02  0:00                                               ` Tarjei T. Jensen
2000-05-02  0:00                                                 ` Preben Randhol
2000-05-02  0:00                                                   ` Strings TP/Ada (was Desirability of C++) Gautier
2000-05-02  0:00                                                   ` Desirability of C++ Keith Thompson
2000-05-03  0:00                                                   ` Tarjei T. Jensen
2000-05-03  0:00                                                     ` Robert A Duff
2000-05-02  0:00                                             ` Gautier
2000-05-01  0:00                                           ` Gautier
2000-05-01  0:00                                             ` Brian Rogoff
2000-05-02  0:00                                               ` Gautier
2000-05-02  0:00                                             ` Ole-Hjalmar Kristensen
2000-05-02  0:00                                           ` Richard D Riehle
2000-05-01  0:00                                         ` Marin D. Condic
2000-05-01  0:00                                       ` Ted Dennison
2000-05-01  0:00                                       ` Tarjei Tj�stheim Jensen
2000-05-01  0:00                                         ` Pascal Obry
2000-05-01  0:00                                           ` Gautier
2000-05-01  0:00                                             ` Ted Dennison
2000-05-01  0:00                                           ` Tarjei Tj�stheim Jensen
2000-05-01  0:00                                         ` Gautier
2000-05-07  0:00                                       ` ANTHONY GAIR
2000-05-07  0:00                                         ` Robert Dewar
2000-05-07  0:00                                         ` Hyman Rosen
2000-05-07  0:00                                           ` ANTHONY GAIR
2000-05-08  0:00                                             ` Hyman Rosen
2000-05-09  0:00                                               ` Pascal Obry
2000-05-11  0:00                                             ` wv12
2000-05-11  0:00                                               ` Frank J. Lhota
2000-05-11  0:00                                               ` Warner Bruns
2000-05-18  0:00                                                 ` Warner Bruns
2000-05-19  0:00                                                   ` ANTHONY GAIR
2000-05-24  0:00                                                   ` Richard Kenner
2000-05-18  0:00                                                 ` ANTHONY GAIR
2000-05-07  0:00                                         ` Richard D Riehle
2000-05-07  0:00                                           ` ANTHONY GAIR
2000-05-08  0:00                                             ` Pascal Obry
2000-05-08  0:00                                               ` Ehud Lamm
2000-05-08  0:00                                                 ` Larry Kilgallen
2000-05-08  0:00                                           ` Mario Klebsch
2000-05-08  0:00                                             ` E. Robert Tisdale
2000-05-08  0:00                                               ` Gautier
2000-05-09  0:00                                               ` Stanley R. Allen
2000-05-10  0:00                                                 ` Alfred Hilscher
2000-05-10  0:00                                                 ` Mario Klebsch
2000-05-08  0:00                                           ` Stanley R. Allen
2000-05-09  0:00                                             ` Richard D Riehle
2000-05-01  0:00                                 ` Ken Garlington
2000-04-29  0:00                         ` Ada on International Space Station (Re: where can we get a job with ada) Chris Johnston
2000-05-01  0:00                           ` Ted Dennison
2000-05-01  0:00                       ` Desirability of C++ Larry Kilgallen
     [not found]                       ` <7EA1B852F5D4D8C6.26EEE9181C8Reply-To: Kilgallen@eisner.decus.org.nospam <Ij4OaidfGTH8@eisner.decus.org>
2000-05-01  0:00                         ` E. Robert Tisdale
2000-03-22  0:00                 ` where can we get a job with ada Florian Weimer
2000-03-05  0:00               ` David Kristola
2000-02-04  0:00 ` Stanley R. Allen
2000-02-04  0:00   ` Stanley R. Allen
2000-02-06  0:00 ` David Tannen
replies disabled

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