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 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,8dc50f1b24590126 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: Nick Roberts Newsgroups: comp.lang.ada Subject: Re: visibility of private incomplete types Date: Sat, 30 Oct 2004 04:13:14 +0100 Message-ID: <2ugf6aF29kg38U1@uni-berlin.de> References: <4180fb61$0$20941$9b4e6d93@newsread2.arcor-online.net> <4181108a_1@baen1673807.greenlnk.net> <9NWdnRZle_mB7RzcRVn-uQ@megapath.net> <2uf1loF27r1iqU1@uni-berlin.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de Bw2WJrIzjH9NAkQsCAoJ7ge4LI5NnYOO5N1SuaAZXr/HM80ec= User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.2) Gecko/20040803 X-Accept-Language: en-us, en In-Reply-To: Xref: g2news1.google.com comp.lang.ada:5900 Date: 2004-10-30T04:13:14+01:00 List-Id: Frank J. Lhota wrote: >>Also, would I be right in saying that, in Ada 95, it is not permitted >>for a type declared (by an incomplete type declaration) in the private >>part of a package to be completed in the package's body? > > No, this was permitted as early as Ada 83, and I used this technique many > times. For example, assume that we are writing a package that implements > widgets. Widgets will be implemented as pointers to a record, but of course > we will hide this implementation detail using a private type. We can also > hide the structure of this record type as follows: > > package Widgets is > > type Widget_Type is limited private; > > procedure Open( Widget : in out Widget_Type; Name : in String ); > procedure Close( Widget : in out Widget_Type ); > ... > > private > > type Widget_Data; > type Widget_Type is access Widget_Data; > > end Widget; > > This type of package specification in legal in both Ada 83 and Ada 95 (and > presumably in Ada 200x), for Widget_Data is never used in a way that > requires a full declaration. Of course, Widget_Data must be fully declared > in the package body. I have to laugh. I now recall that I have used this technique /myself/ in the past. What a memory! RM95 3.10.1 (3). Sorry. -- Nick Roberts