From: joe@petsd.UUCP (Joe Orost)
Subject: Re: Ada language problem/question
Date: Wed, 9-Jul-86 11:52:12 EDT [thread overview]
Date: Wed Jul 9 11:52:12 1986
Message-ID: <794@petsd.UUCP> (raw)
In-Reply-To: 91@houligan.UUCP
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
prev parent reply other threads:[~1986-07-09 15:52 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
1986-07-07 19:15 Ada language problem/question Burch Seymour
1986-07-09 15:18 ` esmith
1986-07-09 15:52 ` Joe Orost [this message]
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox