From: defaria@hpclapd.HP.COM (Andy DeFaria)
Subject: Defered Constants in Ada
Date: 12 Sep 90 21:00:11 GMT [thread overview]
Message-ID: <920029@hpclapd.HP.COM> (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?
next reply other threads:[~1990-09-12 21:00 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
1990-09-12 21:00 Andy DeFaria [this message]
1990-09-13 21:14 ` Defered Constants in Ada Andy DeFaria
1990-09-14 10:48 ` stt
1990-09-14 14:15 ` Arra Avakian
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox