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=-0.8 required=5.0 tests=BAYES_00,INVALID_DATE autolearn=no autolearn_force=no version=3.4.4 Path: utzoo!attcan!uunet!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!sdd.hp.com!hplabs!hpcc01!hpcuhb!hpcllla!hpclisp!hpclapd!defaria From: defaria@hpclapd.HP.COM (Andy DeFaria) Newsgroups: comp.lang.ada Subject: Defered Constants in Ada Message-ID: <920029@hpclapd.HP.COM> Date: 12 Sep 90 21:00:11 GMT Organization: Hewlett-Packard Calif. Language Lab List-Id: 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?