home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!munnari.oz.au!bunyip.cc.uq.oz.au!uqcspe!cs.uq.oz.au!linhoo
- From: linhoo@cs.uq.oz.au (Hu Lin)
- Newsgroups: comp.lang.ada
- Subject: About the ininitialized variables
- Keywords: The assignment to a component of an ininitialized array variable.
- Message-ID: <10000@uqcspe.cs.uq.oz.au>
- Date: 27 Aug 92 01:27:35 GMT
- Sender: news@cs.uq.oz.au
- Reply-To: linhoo@cs.uq.oz.au
- Lines: 25
-
- In Ada, the use of an ininitialized variable in an expression
- will get worning from compiler. But, I found that, for an array variable, if any
- one of its component is assigned with a value then that array variable is also
- accepted as initialized. Is this treatment harmful?
-
- The following is an example I tested.
-
- with TEXT_IO;use TEXT_IO;
- procedure ARR is
- type INT is (a, b);
- type ARR_S is array (INT) of integer;
- C, Y : ARR_S;
- begin
- Y(a) := 5;
- C := Y;
- put_line("C(b) = "&integer'image(C(b)));
- end;
-
- >ada -M arr.a
-
- >a.out
-
- C(b) = 0
-
- ----- linhoo@cs.uq.oz.au
-