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, T_FILL_THIS_FORM_SHORT autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,e01befd2b86cac20 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!fu-berlin.de!uni-berlin.de!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: problems with classes Date: Mon, 4 Oct 2004 10:33:19 +0200 Message-ID: <1gnik0tlsc3av.1i85f33sd3tkx$.dlg@40tude.net> References: <1c2igmxqnybiz.50giqp9woi08$.dlg@40tude.net> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de 50quDb/rSnoqMN1egD5MnwtkK0TWCzEQSDP3QGSuhjegWSQhg= User-Agent: 40tude_Dialog/2.0.12.1 Xref: g2news1.google.com comp.lang.ada:4645 Date: 2004-10-04T10:33:19+02:00 List-Id: On Fri, 1 Oct 2004 20:41:50 +0200, Rick Santa-Cruz wrote: >>> If this would be C++, I think I would know the answer... so in C++ >>> "something like this" exists, too. It is called pre-definition of a type. >>> That means that, for example if I need the name of a type before I wanna >>> specify it, I can just write: >>> class MyType; and specify it later. Is this the case in Ada too? >> >> Close, but not quite. In your example you define the public view of a type >> and later define its implementation. What you meant is a forward type >> declaration, it looks exactly like in C++: > Yes forward declaration ;). > > But if "type Child_Class is new Parent_Class with private;" is not a forward > declaration then what is it then, or what is the sense of this soruce-line? To publish the contract. It is a declaration of the public interface of the type Child_Class. It states: 1. There is a type Child_Class 2. It is a descendant of Parent_Class (maybe an indirect one) The clients of the package can rely on this contract. Forward declaration (incomplete type declaration) does not define any completed contract. So the following is illegal: package Foo is -- ILLEGAL type X; -- Incomplete declaration private type X is range 1..20; -- Type completion, "full view" It makes no sense for public clients. No public view of X is defined, but they cannot look into private. Compare with: package Foo is -- LEGAL type X is private; -- True contract, "public view" private type X is range 1..20; -- Type completion, "full view" Also illegal is: package Foo is -- ILLEGAL type X; -- Promise to complete it here type X is private; -- No, I will not You cannot complete X in the private part, because you have promised that X will be completed in the public part. So either: package Foo is -- LEGAL ... private type X; -- Incomplete declaration type X is range 1..20; -- Type completion and full view or package Foo is -- LEGAL type X; -- Incomplete declaration type X is range 1..20; -- Type completion and full view private ... -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de