comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: tagged record child: override constructor?
Date: Wed, 14 Sep 2005 22:20:41 +0200
Date: 2005-09-14T22:19:46+02:00	[thread overview]
Message-ID: <1aroipmwspnb8.zqxtxhb4t06u$.dlg@40tude.net> (raw)
In-Reply-To: 1126718176.448703.193860@g44g2000cwa.googlegroups.com

On 14 Sep 2005 10:16:16 -0700, Hyman Rosen wrote:

> Dmitry A. Kazakov wrote:
>> meaningful dispatch is rare. How often the specific type is really unknown?
> 
> This is just baffling. The whole point of object-oriented
> programming is that you have classes which conform to an
> interface but have differing implementations, and those
> implementations are dispatched to by making a call using a
> classwide type. That's the whole reason tagged types were
> implemented in Ada 95.

That does not invalidate my point. You need dispatch only if you have a
class-wide object. So if your newbie doesn't write T'Class s/he doesn't
need it.

> Without it, you just have ADTs.

Which is all I need! There is no magic in OO. Class is just an ADT.
Polymorphic object is just a value of that ADT. A polymorphic operation is
just an operation defined on that ADT, which body is composed out of parts
defined by specific types.

>> A goal of Ada design was safe software construction. Putting former C++
>> programmers on the right track wasn't. (:-))
> 
> How nice for Ada. But what does dispatching have to do
> with safety?

It was your point that for a newbie coming from C++ it might appear
difficult to understand Ada. But as it was pointed out many times before,
Ada's default choices are the safest ones. Thus by default an operation on
a tagged type is primitive and dispatching. C++ choices are at most
adventurous. The languages designers had different goals in mind. So for a
newbie it indeed might look as a paradigm shift. High time it is.

>> Because having the tag you can determine the object's type, which might
>> differ from what the contract states. Ada is based on contract model.
> 
> That's how tagged types work. That's the whole point of
> tagged types. You're supposed to be able to get at aspects
> of the object's real type, via dispatching.

That is how *class-wide* types work. Class-wide objects have the type
identity. Specific types need not, because in Ada you cannot dispatch on
them.

>> Because it is the contract to determine what's going on.
> 
> You've got a tagged type, so it's methods should dispatch.
> That's why you use a tagged type in the first place. When
> the method call doesn't dispatch that's surprising and
> unexpected. OO came to Ada late. Making its behavior weirdly
> different from other OO languages isn't helpful.

There is no point in adopting what other languages did wrong.

> The only difference is what type tag
> the object contains when the dispatching happens.

As I said before, it is equivalent to dispatch that does not happen. How
the compiler implements it, by either patching the dispatch table or not, I
don't care. It is a *consistent* behavior, and it is how Ada does it
everywhere.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



  reply	other threads:[~2005-09-14 20:20 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-09-13  5:58 tagged record child: override constructor? sean.gilbertson
2005-09-13  6:39 ` David Trudgett
2005-09-13  7:32 ` Dmitry A. Kazakov
2005-09-13  7:56   ` tmoran
2005-09-13 15:23   ` sean.gilbertson
2005-09-13 17:37     ` Martin Krischik
2005-09-13 19:29       ` Ludovic Brenta
2005-09-14  7:49         ` Dmitry A. Kazakov
2005-09-14  9:05           ` Maciej Sobczak
2005-09-14 13:20             ` Dmitry A. Kazakov
2005-09-14 13:52               ` Hyman Rosen
2005-09-14 16:47                 ` Dmitry A. Kazakov
2005-09-14 17:16                   ` Hyman Rosen
2005-09-14 20:20                     ` Dmitry A. Kazakov [this message]
2005-09-14 20:34                       ` Georg Bauhaus
2005-09-14 20:56                       ` Hyman Rosen
2005-09-15  7:31                         ` Dmitry A. Kazakov
2005-09-15 13:19                           ` Hyman Rosen
2005-09-15 13:45                             ` Maciej Sobczak
2005-09-15 17:45                             ` Dmitry A. Kazakov
2005-09-15 18:54                               ` Hyman Rosen
2005-09-16  9:32                                 ` Dmitry A. Kazakov
2005-09-16 14:52                                   ` Hyman Rosen
2005-09-16 15:33                                     ` Jean-Pierre Rosen
2005-09-16 18:37                                       ` Hyman Rosen
2005-09-16 21:03                                     ` Dmitry A. Kazakov
2005-09-16 21:33                                       ` Hyman Rosen
     [not found]                                         ` <98ox2x9xvj9z.1uh92dslhvt4g.dlg@40tude.net>
2005-09-17 12:47                                           ` Georg Bauhaus
2005-09-17 15:56                                             ` Dmitry A. Kazakov
2005-09-14 16:14           ` Martin Krischik
2005-09-14 16:57             ` Dmitry A. Kazakov
2005-09-14 18:35               ` Martin Krischik
2005-09-14  9:28         ` Alex R. Mosteo
2005-09-14 16:10         ` Martin Krischik
2005-09-13  9:33 ` Georg Bauhaus
2005-09-13 16:37 ` Jeffrey Carter
2005-09-13 18:55   ` Robert A Duff
2005-09-13 22:18     ` Jeffrey Carter
replies disabled

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