comp.lang.ada
 help / color / mirror / Atom feed
* 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

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