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.8 required=5.0 tests=BAYES_00,INVALID_DATE autolearn=no autolearn_force=no version=3.4.4 Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!lll-crg!ames!ucbcad!ucbvax!SDC-CAMARILLO.ARPA!jonab From: jonab@SDC-CAMARILLO.ARPA (Jonathan P. Biggar) Newsgroups: comp.lang.ada Subject: Ambiguity in Ada LRM about private types and type conversions Message-ID: <8611242126.AA09478@PHOEBE.SDC.UUCP> Date: Mon, 24-Nov-86 16:26:41 EST Article-I.D.: PHOEBE.8611242126.AA09478 Posted: Mon Nov 24 16:26:41 1986 Date-Received: Sun, 7-Dec-86 04:23:35 EST Sender: daemon@ucbvax.BERKELEY.EDU Organization: The ARPA Internet List-Id: The following code fragment demonstrates an ambiguity in the Ada Language Reference Manual: package EXPORT is type T is private; private type T is range 0..100; end EXPORT; with EXPORT; use EXPORT; procedure FOO is A: INTEGER; B: T; begin A := INTEGER(B); B := T(A); end FOO; Upon examination of this code, one would expect that a compiler must reject this, because to allow it would mean abrogating the data integrety mechanism provided by private types. If allowed, a user can convert to and from a private type at will. The LRM does not explicitly disallow this however. In 7.4.2(1), the operations declared by a private type declaration include explicit conversions. The intention seems to be to allow explicit conversion between the private type and any types derived from that private type. It also seems to allow the type conversions in the above code. There needs to be a statement in the LRM to explicitly disallow explicit conversions from a private type to types defined compatible to the private type's implementation by 4.6 cases a, b or c. Jon Biggar jonab@SDC-CAMARILLO.ARPA sdcrdcf!jonab