home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / lang / ada / 2450 < prev    next >
Encoding:
Internet Message Format  |  1992-08-26  |  1015 b 

  1. Path: sparky!uunet!munnari.oz.au!bunyip.cc.uq.oz.au!uqcspe!cs.uq.oz.au!linhoo
  2. From: linhoo@cs.uq.oz.au (Hu Lin)
  3. Newsgroups: comp.lang.ada
  4. Subject: About the ininitialized variables
  5. Keywords: The assignment to a component of an ininitialized array variable.
  6. Message-ID: <10000@uqcspe.cs.uq.oz.au>
  7. Date: 27 Aug 92 01:27:35 GMT
  8. Sender: news@cs.uq.oz.au
  9. Reply-To: linhoo@cs.uq.oz.au
  10. Lines: 25
  11.  
  12. In Ada, the use of an ininitialized variable in an expression
  13. will get worning from compiler. But, I found that, for an array variable, if any
  14. one of its component is assigned with a value then that array variable is also
  15. accepted as initialized. Is this treatment harmful?
  16.  
  17. The following is an example I tested.
  18.  
  19.         with TEXT_IO;use TEXT_IO;
  20.         procedure ARR is
  21.         type INT is (a, b);
  22.         type ARR_S is array (INT) of integer;
  23.         C, Y : ARR_S;
  24.         begin
  25.         Y(a) := 5;
  26.         C := Y;
  27.         put_line("C(b) = "&integer'image(C(b)));
  28.         end;
  29.  
  30.         >ada -M arr.a
  31.  
  32.         >a.out
  33.  
  34.         C(b) = 0 
  35.  
  36. ----- linhoo@cs.uq.oz.au
  37.