comp.lang.ada
 help / color / mirror / Atom feed
From: "Hyman Rosen" <hyman.rosen@gmail.com>
Subject: Re: tagged record child: override constructor?
Date: 15 Sep 2005 11:54:15 -0700
Date: 2005-09-15T11:54:15-07:00	[thread overview]
Message-ID: <1126810455.448696.262570@g44g2000cwa.googlegroups.com> (raw)
In-Reply-To: 1w82ustqd4vak$.mv9c3tcxa6sx.dlg@40tude.net

Dmitry A. Kazakov wrote:
> There is no actual type, there is only the type specified by the contract.

There is an actual type, and it can be recovered from the object
through redispatching (or even by simply extracting the type tag,
if I'm not mistaken).

> That's your view on OO, which is clearly inconsistent with the notion of
> types.

Perhaps with your notions of types.

> is "by-reference" a type property?

Yes. In C++ you have "type" and "reference to type" and the two
are completely different. A "reference to type" may have as its
referant a sub-object of the given type which is a base class of
a larger object. An object of "type" is exactly that. Both of
these concepts are useful.

> Why by-copy objects (of which type?) have one (which?) type while
> by-reference objects (of which type?) have more than one?

It's not the "by-copy" that gives something a type. When you declare
that a parameter has a class type, it has that type and nothing more.
It's a separate object within its lifetime, and when the function is
called, it's initialized with a copy of the argument. When you have
a parameter of reference type, when the function is called it's
initialized to refer to the appropriate subobject of the argument.
(Actually, newbies in C++ face the same confusion between paramaters
of T and T& as Ada newbies do between T and T'Class.)

> It is rubbish. In a typed language an object has a type, only one type.

You may not like it, but that's the way it's done, including in Ada.

> No. Trap is when the declared type does not determine what's going on.

In C++ the declared type does determine what's going on.
In Ada, you are permitted to go from the declared type to the
classwide type, so by your argument C++ reflects the contract
model better than Ada does.

> I (again) formulate the properties of Ada's model:

But no Ada compiler implements the model the way you would like
it to be. And I believe that allowing conversion from T to T'Class
is a requirement of Ada.

> Now show me how C++ or Java could accomplish 1..12.

C++ doesn't have polymorphic variables or copying, so some things
are out of reach. But the main problem with your approach is that
no one wants to implement differently sized pointers for T'Class
than for T. For all your posting on this, I've yet to see an
implementor so taken by your approach that he's willing to adopt it.

> What should that code prove? That pointers to members is a total mess in
> C++? Everybody knows it.

It proves that they're equal. *That's* what everyone knows.

> I don't know what "separate" members are. Do you mean memory location? Why
> should I care of?

I mean "different", or "distinct", or "not the same", or any other
synonym you care to pick.

> They cannot be same because they act on different types. You cannot call
> B::g() on A. The same question again, is C++ typed?

As I said, in OO languages like Ada, C++, and Java, when you have a
reference type, the object to which it refers may be a typed base
subobject of a larger object of different type. There is only an
A::g(),
and it operates on an A object which is standalone or which is a base
subobject of an object of a class derived from A. Because B inherits
g() from A, you may also refer to it as B::g, much as Ada lets you
rename one thing as another, but it is only a different name for the
same thing. And if you have a 'B b;' it's perfectly legal to say
'b.A::g();'.

> X->B::g (); // Error, how so? X is of B, or maybe not quite?

Because the rules of C++ (3.4.5/4 of the Standard, if you would like
to check) say that the name preceding the :: is first looked up in
context. There is no B in A, so it simply fails to compile without
ever getting to consider the g() part.




  reply	other threads:[~2005-09-15 18:54 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
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 [this message]
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