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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,cd029b9d6c03962d X-Google-Attributes: gid103376,public From: Stephen Leake Subject: Re: Can't hide parts of ADTs in private children Date: 1998/11/09 Message-ID: #1/1 X-Deja-AN: 410013873 References: <364683EB.41C6@syd.csa.com.au> Organization: NASA Goddard Space Flight Center -- Greenbelt, Maryland USA Newsgroups: comp.lang.ada Date: 1998-11-09T00:00:00+00:00 List-Id: David Bowerman writes: > I am implementing an Abstract Data Type (Class) in a package. The code > goes something like this: > > package Class_X_Package is > > type Class_X is private; > type Class_X_Ptr is access Class_X; > > ... operations on objects of type X > > private > > type Class_X is > record > Component_A : Type_A; > Component_B : Type_B; > ... > end record; > > end Class_X_Package; > > The abstract data type (X) is complex, and Type_A, Type_B, etc hide a > lot of structure within themselves. > I would like to break the package down further, declare the types, and > generally hide the details of, Type_A, Type_B, etc (never intended to be > visible to the client) in private child packages. Why do Type_A, Type_B belong in child packages, instead of in library packages? In building an ADT, you can use facilities of a library, while making it clear that the user of your ADT should not use the library directly. Unless Type_A depends on something else in Class_X_Package, just put it in its own library level package. > But I can't do this because these types are referred to in the private > part of the parent package spec, and this isn't allowed to 'with' its > children. > > Can anyone suggest another way of doing it. Alternatively, make Class_X an access type, which allows you to defer the full type definition to the package body, where you can 'with' child packages. -- Stephe