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=0.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fac41,c52c30d32b866eae X-Google-Attributes: gidfac41,public X-Google-Thread: 103376,2ea02452876a15e1 X-Google-Attributes: gid103376,public X-Google-Thread: 1108a1,c52c30d32b866eae X-Google-Attributes: gid1108a1,public From: ncohen@watson.ibm.com (Norman H. Cohen) Subject: Re: Real OO Date: 1996/03/22 Message-ID: <4iv58e$113p@watnews1.watson.ibm.com>#1/1 X-Deja-AN: 143753443 distribution: world references: <4id031$cf9@dayuc.dayton.saic.com> organization: IBM T.J. Watson Research Center reply-to: ncohen@watson.ibm.com newsgroups: comp.lang.ada,comp.lang.eiffel,comp.object Date: 1996-03-22T00:00:00+00:00 List-Id: When Don Harrison asked how to achieve selective export in Ada, I proposed a technique, but I never asked why one would want selective export. Selective export does indeed help document the modular structure of a program, and make the program easier for a reader to understand, but it seems to me that the documentation is in the wrong place. In general, the writer of a program component should be as unaware as possible of the context in which that component will be used, especially if loose coupling and reusability are valued. I don't find Bertrand Meyer's example of selective export in _Object-Oriented_Software_Construction_ particularly compelling. That example would be written in Ada as follows: generic type Element_Type is private; package Lists is type List_Type is private; ... private type Cell_Type; type Cell_Pointer_Type is access Cell_Type; type Cell_Type is record Data : Element_Type; Link : Cell_Pointer_Type; end record; type List_Type is record Length : Natural; Cells : Cell_Pointer_Type; end record; end Lists; However, because of the Eiffel constraint that module = class = type, Meyer cannot define List_Type in the same class as Cell_Type. Therefore, he puts his equivalent of Cell_Type in a separate class which is selectively exported only to the List_Type class. (There is no need for an explicit Cell_Pointer_Type in Eiffel because of Eiffel's implicit reference semantics; the Link component belongs to Cell_Type.) Perhaps Don will decry this as "quasi-encapsulation", but the whole point of the selective export in Eiffel was to emphasize that the Eiffel class corresponding to Cell_Pointer_Type was to be used only in the module defining the Eiffel analog of List_Type. Nesting multiple type definitions (suitably hidden) inside a single Ada package accomplishes the same thing. Because of the ability to define more than one type in the same module in Ada, selective export is of less interest to an Ada programmer than to an Eiffel programmer. -- Norman H. Cohen ncohen@watson.ibm.com