* Defered Constants in Ada
@ 1990-09-12 21:00 Andy DeFaria
1990-09-13 21:14 ` Andy DeFaria
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Andy DeFaria @ 1990-09-12 21:00 UTC (permalink / raw)
I have been trying to use defered constants in Ada and I have been have
some problems. Everything seems to be OK if the type of the defered
constant is local but if the type is imported then the compiler issues the
error message that follows:
----HP Ada/800 A.04.35------------------------------------------------------
Source file : /tmp/note.ads
In Ada library: /tmp/adalib Next message at line: 18
-------------------------------------------------------------------------------
1 package PACKAGE_ONE is
2
3 type EXPORTED_TYPE is private;
4
5 private
6 type EXPORTED_TYPE is new STANDARD.INTEGER;
7
8 end PACKAGE_ONE;
9
10 with UNCHECKED_CONVERSION;
11 with PACKAGE_ONE;
12
13 package PACKAGE_TWO is
14
15 type LOCAL_TYPE is private;
16
17 DEFFERED_CONSTANT_1 : constant LOCAL_TYPE;
18 DEFFERED_CONSTANT_2 : constant PACKAGE_ONE.EXPORTED_TYPE;
<--------------------------1--------------------------->
1 **SEM 3018 A constant must be initialised - RM 3.2.1 (2).
19
20 private
21 function CONVERT is new UNCHECKED_CONVERSION
22 (SOURCE => INTEGER, TARGET => PACKAGE_ONE.EXPORTED_TYPE);
23
24 type LOCAL_TYPE is new STANDARD.INTEGER;
25
26 DEFFERED_CONSTANT_1 : constant LOCAL_TYPE
27 := 0;
28 DEFFERED_CONSTANT_2 : constant PACKAGE_ONE.EXPORTED_TYPE
29 := CONVERT (0);
30
31 end PACKAGE_TWO;
One error detected. No warning issued. Compilation failed.
Faulty line is:
-------------------------------------------------------------------------------
**:18
One error detected. No warning issued. Compilation failed.
The real question is why is DEFFERED_CONSTANT_1 OK while
DEFFERED_CONSTANT_2 wrong?
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Defered Constants in Ada
1990-09-12 21:00 Defered Constants in Ada Andy DeFaria
@ 1990-09-13 21:14 ` Andy DeFaria
1990-09-14 10:48 ` stt
1990-09-14 14:15 ` Arra Avakian
2 siblings, 0 replies; 4+ messages in thread
From: Andy DeFaria @ 1990-09-13 21:14 UTC (permalink / raw)
>/ hpclapd:comp.lang.ada / defaria@hpclapd.HP.COM (Andy DeFaria) / 2:00 pm Sep 12, 1990 /
>I have been trying to use defered constants in Ada and I have been have
>some problems. Everything seems to be OK if the type of the defered
>constant is local but if the type is imported then the compiler issues the
>error message that follows:
Thanks for the email responses to this question. It turns out that this is
explicitly forbidden by the Ada LRM 7.4 (4) with states that the type mark
for the defered constant must but declared in the same package.
Stupid me! I know RTFM, RTFM, RTFM....
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Defered Constants in Ada
1990-09-12 21:00 Defered Constants in Ada Andy DeFaria
1990-09-13 21:14 ` Andy DeFaria
@ 1990-09-14 10:48 ` stt
1990-09-14 14:15 ` Arra Avakian
2 siblings, 0 replies; 4+ messages in thread
From: stt @ 1990-09-14 10:48 UTC (permalink / raw)
Re: Deferred Constants in Ada
Quoting from RM 7.4(4):
"... a deferred constant declaration and the declaration of
the corresponding private type must both be declarative items
of the visible part of the same package."
It is interesting that this limitation is not mentioned
anywhere in the subsection devoted to Deferred Constants, but
only in the introduction to the section on
private types and deferred constants.
S. Tucker Taft
Intermetrics, Inc.
Cambridge, MA 02138
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Defered Constants in Ada
1990-09-12 21:00 Defered Constants in Ada Andy DeFaria
1990-09-13 21:14 ` Andy DeFaria
1990-09-14 10:48 ` stt
@ 1990-09-14 14:15 ` Arra Avakian
2 siblings, 0 replies; 4+ messages in thread
From: Arra Avakian @ 1990-09-14 14:15 UTC (permalink / raw)
In article <920029@hpclapd.HP.COM> defaria@hpclapd.HP.COM (Andy DeFaria) writes:
>I have been trying to use defered constants in Ada and I have been have
>some problems. Everything seems to be OK if the type of the defered
>constant is local but if the type is imported then the compiler issues the
>error message that follows:
(Example deleted to save space)
From LRM 7.4(4): "...; a deferred constant declaration and the declaration of
the corresponding private type must both be declarative items of the visible
part of the same package."
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~1990-09-14 14:15 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1990-09-12 21:00 Defered Constants in Ada Andy DeFaria
1990-09-13 21:14 ` Andy DeFaria
1990-09-14 10:48 ` stt
1990-09-14 14:15 ` Arra Avakian
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox