From: Hyman Rosen <hymie@prolifics.com>
Subject: Re: Private Children
Date: 1999/06/24
Date: 1999-06-24T16:27:38+00:00 [thread overview]
Message-ID: <t7emj1y32b.fsf@calumny.jyacc.com> (raw)
In-Reply-To: 7krq1m$m2@dfw-ixnews5.ix.netcom.com
Richard D Riehle <laoXhai@ix.netcom.com> writes:
> In Mr. Freeman's Ada example, he assumes that the private part of
> the package must contain a complete view of the data. That is exactly
> the opposite of the example I posted earlier.
which was --
package P is
type T is tagged private;
-- operations on T
private
type Item;
type Item_Pointer is access all Item;
type T is tagged record
Data : Item_Pointer; -- a reference to hidden data
end record;
end P;
> In Ada, we can declare an incomplete type, an access to that type,
> enclose within a tagged record a value of the access type, and defer
> the full description of the data until later. This is the essence of
> an opaque type. Opaque types are convenient in both Ada and Modula-3
> because of their clear separation of interface module (package
> specification) from implementation module (package body). This is
> more difficult in Java, C++, and even Eiffel, as demonstrated in
> Mr. Freeman's article.
In C++ we can do the following. I'm not sure if I've duplicated the
semantics you're aiming for, but I think I did. Unless I'm not
understanding your intent, I don't see why my C++ is any more
difficult than your Ada.
class P
{
private:
class Item;
typedef Item *Item_Pointer;
public:
class T
{
public:
// operations on T
private:
Item_Pointer Data;
};
};
next prev parent reply other threads:[~1999-06-24 0:00 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-06-20 0:00 Private Children Matthew Heaney
1999-06-21 0:00 ` Dale Stanbrough
1999-06-21 0:00 ` Ted Dennison
1999-06-21 0:00 ` Tucker Taft
1999-06-21 0:00 ` Matthew Heaney
1999-06-21 0:00 ` Tucker Taft
1999-06-22 0:00 ` Richard D Riehle
1999-06-22 0:00 ` Dale Stanbrough
1999-06-22 0:00 ` Matthew Heaney
1999-06-23 0:00 ` Dale Stanbrough
1999-06-23 0:00 ` Matthew Heaney
1999-06-23 0:00 ` Dale Stanbrough
1999-06-23 0:00 ` Richard D Riehle
1999-06-23 0:00 ` John Duncan
1999-06-23 0:00 ` Vladimir Olensky
1999-06-23 0:00 ` Richard D Riehle
1999-06-24 0:00 ` Hyman Rosen [this message]
1999-06-24 0:00 ` Richard D Riehle
1999-06-24 0:00 ` Dale Stanbrough
1999-06-22 0:00 ` Richard D Riehle
1999-06-21 0:00 ` Matthew Heaney
1999-06-25 0:00 ` Robert Dewar
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox