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=2.6 required=5.0 tests=BAYES_20,INVALID_DATE, MSGID_SHORT,REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!caip!seismo!nbires!hao!hplabs!pesnta!peora!petsd!joe From: joe@petsd.UUCP (Joe Orost) Newsgroups: net.lang.ada Subject: Re: Ada language problem/question Message-ID: <794@petsd.UUCP> Date: Wed, 9-Jul-86 11:52:12 EDT Article-I.D.: petsd.794 Posted: Wed Jul 9 11:52:12 1986 Date-Received: Fri, 11-Jul-86 06:22:54 EDT References: <91@houligan.UUCP> Reply-To: joe@petsd.UUCP (Joseph M. Orost) Organization: Perkin-Elmer DSG, Tinton Falls, N.J. Summary: subtype doesn't give you the literals List-Id: In article <91@houligan.UUCP> bseymour@houligan.UUCP (Burch Seymour) writes: >package A is >type my_type is (st_1,st_2,st_3); >end A; > >package body A is >x : my_type; >begin >x := st_1; -- no errors here >end A; >------------------------------------------------------------------------ >with A; >package B is --Solution #1 : replace next line with "TYPE my_type IS NEW a.my_type" >subtype my_type is a.my_type; --Solution #2 : add the following lines: FUNCTION st_1 RETURN my_type RENAMES a.st_1; FUNCTION st_2 RETURN my_type RENAMES a.st_2; FUNCTION st_3 RETURN my_type RENAMES a.st_3; >end B; > >Package body B is >y : my_type; >begin --Change the following to "y := st_2;" >y := A.st_2; -- no errors here >end B; >------------------------------------------------------------------------ >with B; >package C is >I : B.my_type; -- type is OK but appears to fail to bring along > -- enumeration values (see below). The question is... > -- should it? >end C; > >Package body C is >begin >I := B.st_3; -- undeclared identifier error on this assign > -- sites section 8.3 of LRM >end c; Explanation: A subtype declaration does not bring with it the operations (enumeration literals) of the parent type. A DERIVED type declaration does [3.4(6)]. So either use a derived type, or rename all the literals. regards, joe -- Full-Name: Joseph M. Orost UUCP: ihnp4!vax135!petsd!joe ARPA: vax135!petsd!joe@BERKELEY Phone: (201) 758-7284 Location: 40 19'49" N / 74 04'37" W US Mail: MS 313; Concurrent Computer Corporation; 106 Apple St Tinton Falls, NJ 07724