🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: net.lang.ada
Article #867

Re: Ada language problem/question

#867
From: Joe Orost
Date: Wed, 09 Jul 1986 15:52
57 lines
2306 bytes
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
Technical Details
Message-ID: <794@petsd.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!caip!seismo!nbires!hao!hplabs!pesnta!peora!petsd!joe
References: <91@houligan.UUCP>

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: arc1-ca.pugleaf.net!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.
Lines: 57
Summary: subtype doesn't give you the literals