comp.lang.ada
 help / color / mirror / Atom feed
From: dewar@merv.cs.nyu.edu (Robert Dewar)
Subject: Re: C vs Ada code quality
Date: 1997/04/26
Date: 1997-04-26T00:00:00+00:00	[thread overview]
Message-ID: <dewar.862056422@merv> (raw)
In-Reply-To: 336163A0.7B56@pratique.fr


<<I know that ! In fact this is about Ada vs The Rest of the Universe>>

First, I am not quite sure what you mean by *this*! You were replying to
a thread which was specificaly discussing C and not C++. Second, I guess
you must have a very limited view of the universe if you think it only
contains Ada, C and C++ (do some investigation some time about what is
atually used for development these days, the entries for COBOL, Delphi,
Java, and especially Visual Basic may suprise you, not to mention the
4GL's.

<<I'm not a specialist of Ada, but it seem to me that the analogy
is imcomplete since C++ rely on overloading (compile time)
and Ada on overiding (run time).>>

Right, you are not a specialist in Ada, and your guesses are wrong. I will
say this again, quite clearly this time I hope: The controlled types in
Ada are exactly equivalent to the destructors in C++. They involve
dispatching only when it would also be neessary in C++. I don't know what
leads to your misconceptions here, but they are misconceptions.

Probably you are confusing the formal description with the implementation.
The fact that controlled types in Ada are derived from controlled does
not mean you have to implement them any differently from C++. 

<<Ok, ok, like the dynamic type of an object in C++ (ie the
  vtable pointer - no, this word, vtable, is only there to
  annoy you).>>

Huh? Why should the use of the word vtable annoy me? I know perfectly
well how typical implementations of of C++ use vtable pointers. You
should look sometime at the implementation of GNAT/C++ interfacing
which shows how vtable pointers are mapped into the GNAT/Ada 95
environment.

HOWEVER, the ie here is very wrong (ie means "that is"). A vtable is
not the dynamic type of the object. The latter is a formal semantic
concept in the language. A vtable is one possible implementation
approach. There is nothing in C++ that requires the use of the vtable
approach, and there are other possibilities.

<<No no no, I am *not* comparing a particular implementation>>

yes,yes,yes you *are* comparing a particular implementation. You just don't
realize what the distinction is between what is required in the semantics
and what a typical implementation uses to provide these semantics.

In both Ada and C++, finalization (destructors) are defined on individual
types, and have to be called at the right time. End of story, no significant
difference! Now you may wonder why in practice C++ implementations have
avoided the use of dynamic lists for finalization, and Ada implementations
have often used them. The answer is simple. Once you have to deal with
exceptions the dynamic list has real advantages -- the C++ world is
working through these problems now -- for example, see the discussions
with respect to g++ and exeptions, where recently someone seriously
suggested the possibility of going to lists for handling destructors.

<<But is it different in Ada ? Does the 'aliased' keyword really
help ? Does this keyword serve any purpose (the compiler can
look at the source to see if you are taking accesses to a
variable directly) ? Is it like the register keyword in C (ie
the semantic of a register variable is the same but you can't
take its address) ?>>

Of course not! You are forgetting separate compilation -- the same problem
of course arises in C. Yes, you can sometimes tell for local variables
(e.g. in the absence of subunits), but in C and C++ global variables
have to be assumed to be aliased, and this is not the case in Ada.






  reply	other threads:[~1997-04-26  0:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-04-24  0:00 C vs Ada code quality Robert Dewar
1997-04-26  0:00 ` Valentin Bonnard
1997-04-26  0:00   ` Robert Dewar [this message]
1997-04-29  0:00     ` Richard Kenner
  -- strict thread matches above, loose matches on Subject: below --
1997-05-01  0:00 Valentin Bonnard
replies disabled

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