comp.lang.ada
 help / color / mirror / Atom feed
From: Hyman Rosen <hyrosen@mail.com>
Subject: Re: Package Instances???
Date: Fri, 22 Feb 2002 15:55:40 -0500
Date: 2002-02-22T15:55:40-05:00	[thread overview]
Message-ID: <3C76B04C.7050108@mail.com> (raw)
In-Reply-To: u7d6mhf39qft76@corp.supernews.com

Matthew Heaney wrote:
> "Hyman Rosen" <hyrosen@mail.com> wrote
>>Depending on how one builds it, a C++ class or class template
>>can fulfill the role of an Ada package, record, or tagged type.
> 
> We all agree it's not a perfect comparison, since a class in C++ has type
> semantics and module semantics, and in Ada they are orthogonal.

Of course it's not a perfect comparison! We are talking about
two different and largely independent programming languages.


> Wrong.  An Ada package is a C++ namespace.  An Ada private type is a C++
> class.  The fact that genericity is attached to modules in Ada rather than
> to the type itself is irrelevant.

An Ada package is not a C++ namespace, since it's written
in Ada, not in C++. The issue we're dealing with is how to
best represent the construct of one programming language in
another. When one construct has many aspects to it, it is
likely that such cross-language representation will depend
on which aspect is pre-eminent.

In Ada, a package may be passed as a parameter to a generic
instantiation. A package body may have a begin-end section
which runs when the package is elaborated. You mat have a
generic package. The proper way to represent these abilities
in C++ is as a class or class template, not a namespace. You
may have some Ada packages which don't make use of any of
these features, and those can be represented as namespaces,
but that is not the case in general.


> Well, if a C++ class has virtual methods, then it has a vtable, which
> exactly corresponds to an Ada tagged type.  A C++ class sans virtual methods
> has no vtable, and hence is equivalent to a nontagged Ada type.

An Ada tagged type is best represented as a C++ class with virtual
methods. An Ada untagged record type is best represented as a C++
class without virtual methods. Notice that the direction here in
both cases is how to represent an Ada construct in C++. Your second
statement is completely false, however, because a C++ class may
contain type definitions, constant definitions, and non-member
functions, none of which are present in an untagged Ada type, but
which *are* present in an Ada package.

> A C++ class is an Ada type.  The fact that a C++ class has module
 > semantics too is irrelevant.

You may assert that all you like, but that will not make it true.
Here's a C++ class: class c { typedef int t; enum { v = 3 }; };
What is the corresponding Ada type?

> Thankfully Stroustrup has tempered this unbridled enthusiasm for all things
> "pure object-oriented" by demonstrating the benefits of non-extensible types
> and static method binding.

Actually, all classes in C++ are extensible, but whatever.
Anyway, the exciting C++ stuff these days is in template
metaprogramming, which is pretty much inexpressible in Ada.




  reply	other threads:[~2002-02-22 20:55 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-02-13 21:02 Package Instances??? Yates
2002-02-13 21:12 ` Larry Kilgallen
2002-02-13 21:21 ` chris.danx
2002-02-13 21:46 ` Marin David Condic
2002-02-14 17:59   ` Hyman Rosen
2002-02-15 13:11     ` Marc A. Criley
2002-02-15 19:20     ` Simon Wright
2002-02-19 14:08       ` Marin David Condic
2002-02-20  1:37         ` Matthew Heaney
2002-02-20 16:56           ` Marin David Condic
2002-02-21 15:33             ` Matthew Heaney
2002-02-20 19:16           ` Hyman Rosen
2002-02-20 22:31             ` Pat Rogers
2002-02-20 23:44             ` Matthew Heaney
2002-02-21  5:35               ` Hyman Rosen
2002-02-21 14:05                 ` Marin David Condic
2002-02-22 16:49                   ` Hyman Rosen
2002-02-22 17:22                     ` Marin David Condic
2002-02-24  7:39                       ` Hyman Rosen
2002-02-25 15:38                         ` Matthew Heaney
2002-02-22 18:10                     ` Matthew Heaney
2002-02-22 20:55                       ` Hyman Rosen [this message]
2002-02-22 21:37                         ` Matthew Heaney
2002-02-24  7:36                           ` Hyman Rosen
2002-02-25 15:27                             ` Matthew Heaney
2002-02-21 15:30                 ` Matthew Heaney
2002-02-21 18:05                   ` Hyman Rosen
2002-02-13 21:50 ` Eric Merritt
2002-02-14 15:08 ` Yates
replies disabled

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