From: pitre@n5160d.nrl.navy.mil (Richard Pitre)
Subject: Re: some questions re. Ada/GNAT from a C++/GCC user
Date: 1996/03/30
Date: 1996-03-30T00:00:00+00:00 [thread overview]
Message-ID: <4jjul6$637@ra.nrl.navy.mil> (raw)
In-Reply-To: Dp1sMM.23q@world.std.com
In article <Dp1sMM.23q@world.std.com> bobduff@world.std.com (Robert A Duff)
writes:
> In article <leschkes.828053356@ferret>,
> Scott Leschke <leschkes@ferret.cig.mot.com> wrote:
> >My first question would be, why do you want redundant instantiations.
>
> Usually you don't. But you might declare a type Apple_Count, and not
> know whether anybody wants to do I/O on it. Then one client does, and
> instantiates Text_IO.Integer_IO on Apple_Count. And another client
> independently does the same. One might like to share the code of the
> two instantiations.
>
> But, as Bill Newman pointed out, the more important thing is when you
> have Apple_Count and Orange_Count, which are logically distinct, but
> happen to share the same hardware representation. That's a more
> important case where you'd like shared generic code.
>
> Shared generic code isn't easy to implement in general, but many Ada 83
> compilers support it, at least for some kinds of generics. The problem
> is that you can't count on it in portable code, so you have to do it "by
> hand". That's not so awful, I suppose -- at least the ugly parts are
> buried in one place.
>
> >You can use a block statement. This is different than C++ in the sense
> >that objects declared within the block are only in existence within the
> >block and are finalized at the end.
>
> No, I think this is exactly the same in C++ and Ada. See r.6.7 of The
> C++ Programming Language, Second Edition, by Bjarne Stroustrup. That
> is, if you declare an object in C++ in a local sequence of statements,
> it will be finalized at the end of that sequence.
> The only difference
> is that Ada requires some extra syntactic baggage.
>
> >declare
> > Obj : Pkg.SomeType;
> >begin
> > Pkg.Operation (Object => Obj);
> > -- Other stuff
> >exception
> > when Pkg.Some_Exception =>
> >
> > Do_Something;
> >end;
>
> The exception handler makes this look reasonable, but in the usual case,
> where there's no need for any exception handling, and you just want to
> declare Obj, the extra 3 lines of code ("declare", "begin", "end") are
> just an annoyance.
I thing of "begin" and "end" are visual cues and I prefer them to eyeburner
baggage like "{" and "}".
richard
next prev parent reply other threads:[~1996-03-30 0:00 UTC|newest]
Thread overview: 80+ messages / expand[flat|nested] mbox.gz Atom feed top
1996-03-27 0:00 some questions re. Ada/GNAT from a C++/GCC user Bill Newman
1996-03-27 0:00 ` Robert Dewar
1996-03-28 0:00 ` Norman H. Cohen
1996-03-28 0:00 ` Brian Rogoff
1996-03-29 0:00 ` John G. Volan
1996-03-30 0:00 ` Robert A Duff
1996-03-31 0:00 ` Robert Dewar
1996-04-01 0:00 ` Norman H. Cohen
1996-03-31 0:00 ` John G. Volan
1996-03-31 0:00 ` Mike Young
1996-04-02 0:00 ` Glenn H. Porter
1996-04-02 0:00 ` Robert Dewar
1996-04-02 0:00 ` Jonas Nygren
1996-04-03 0:00 ` Geert Bosch
1996-04-03 0:00 ` Robert Dewar
1996-04-01 0:00 ` Bruce.Conroy
1996-04-01 0:00 ` Robert A Duff
1996-04-03 0:00 ` Scott Leschke
1996-04-04 0:00 ` AdaWorks
1996-03-30 0:00 ` Mike Young
1996-03-30 0:00 ` Ted Dennison
1996-03-31 0:00 ` Mike Young
1996-04-01 0:00 ` Norman H. Cohen
1996-04-01 0:00 ` Mike Young
1996-04-02 0:00 ` David Shochat
1996-04-02 0:00 ` Mike Young
1996-04-02 0:00 ` Norman H. Cohen
1996-04-02 0:00 ` Robert Dewar
1996-04-01 0:00 ` Robert A Duff
1996-04-01 0:00 ` Mike Young
1996-04-02 0:00 ` Robert A Duff
1996-04-02 0:00 ` Norman H. Cohen
1996-03-28 0:00 ` Ted Dennison
1996-03-29 0:00 ` Adam Beneschan
1996-03-28 0:00 ` Scott Leschke
1996-03-29 0:00 ` Robert I. Eachus
1996-03-29 0:00 ` Robert A Duff
1996-03-30 0:00 ` Richard Pitre [this message]
1996-03-30 0:00 ` Robert A Duff
1996-03-31 0:00 ` AdaWorks
1996-04-01 0:00 ` Robert A Duff
1996-04-01 0:00 ` AdaWorks
1996-04-01 0:00 ` Mike Young
1996-04-02 0:00 ` AdaWorks
1996-04-02 0:00 ` Robert Dewar
1996-04-01 0:00 ` Norman H. Cohen
1996-04-01 0:00 ` Ken Garlington
1996-04-01 0:00 ` Robert A Duff
1996-04-02 0:00 ` Ken Garlington
1996-04-02 0:00 ` Robert A Duff
1996-04-02 0:00 ` Ken Garlington
1996-04-02 0:00 ` Robert A Duff
1996-04-03 0:00 ` David Emery
1996-04-03 0:00 ` Ken Garlington
1996-04-09 0:00 ` Matt Kennel
1996-04-02 0:00 ` Tucker Taft
1996-04-02 0:00 ` Felaco
1996-04-02 0:00 ` Robert Dewar
1996-04-03 0:00 ` Mark A Biggar
1996-04-01 0:00 ` Robert Dewar
1996-04-01 0:00 ` Richard A. O'Keefe
1996-04-01 0:00 ` Robert A Duff
1996-04-02 0:00 ` Robert I. Eachus
1996-03-29 0:00 ` Bill Newman
1996-03-29 0:00 ` Robert A Duff
1996-03-29 0:00 ` Brian Rogoff
1996-04-01 0:00 ` Mark A Biggar
1996-04-01 0:00 ` Robert A Duff
1996-03-30 0:00 ` Iterators (was Re: some questions re. Ada/GNAT from a C++/GCC user) Robert I. Eachus
1996-03-31 0:00 ` Mike Young
1996-03-31 0:00 ` Fergus Henderson
1996-04-01 0:00 ` Robert I. Eachus
[not found] ` <4jlj79$h1k@Nntp1.mcs.net>
1996-04-01 0:00 ` some questions re. Ada/GNAT from a C++/GCC user Robert A Duff
1996-04-02 0:00 ` Kevin Cline
1996-04-02 0:00 ` Robert A Duff
1996-04-04 0:00 ` Jon S Anthony
1996-03-30 0:00 ` Simon Wright
1996-04-01 0:00 ` Laurent Guerby
1996-04-01 0:00 ` Robert A Duff
-- strict thread matches above, loose matches on Subject: below --
1996-03-28 0:00 Simon Johnston
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox