From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,faf469c89f73f91d X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-02-22 12:54:27 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!cpk-news-hub1.bbnplanet.com!nycmny1-snh1.gtei.net!news.gtei.net!news-out.visi.com!hermes.visi.com!uunet!ash.uu.net!spool0900.news.uu.net!reader0900.news.uu.net!not-for-mail Message-ID: <3C76B04C.7050108@mail.com> Date: Fri, 22 Feb 2002 15:55:40 -0500 From: Hyman Rosen User-Agent: Mozilla/5.0 (Windows; U; WinNT4.0; en-US; rv:0.9.8+) Gecko/20020213 X-Accept-Language: en-us MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Package Instances??? References: <721b6d80.0202131302.1ccce2ed@posting.google.com> <3C6BFAFC.7060902@mail.com> <3C73F5F6.7050704@mail.com> <3C7487D6.5060603@mail.com> <3C7676AF.9020404@mail.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Organization: KBC Financial Products Cache-Post-Path: master.nyc.kbcfp.com!unknown@mosquito.nyc.kbcfp.com X-Cache: nntpcache 2.3.3 (see http://www.nntpcache.org/) NNTP-Posting-Host: 204.253.250.10 X-Trace: 1014411266 reader0.ash.ops.us.uu.net 26460 204.253.250.10 Xref: archiver1.google.com comp.lang.ada:20265 Date: 2002-02-22T15:55:40-05:00 List-Id: Matthew Heaney wrote: > "Hyman Rosen" 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.