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!utgpu!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!rutgers!ucsd!ucbvax!compass.UUCP!worley From: worley@compass.UUCP (Dale Worley) Newsgroups: comp.lang.ada Subject: Use of undefined variables Message-ID: <8812061623.AA28613@galaxy.compass.com> Date: 6 Dec 88 16:23:39 GMT Sender: daemon@ucbvax.BERKELEY.EDU Organization: The Internet List-Id: Really? Consider the following: procedure FUN_WITH_UNDEFINED_VARIABLES is A : INTEGER; -- A is undefined... B : INTEGER; -- B is undefined... begin A := B; -- Quick, what value does A have? end FUN_WITH_UNDEFINED_VARIABLES; This compiles and executes under Alsys Ada. According to RM 3.2.1(18), "The execution of a program is erroneous if it attempts to evaluate a scalar variable with an undefined value." Thus, that it works under Alsys is accidental. In re the original point: > The ADT-handling package may feel like leaving a component undefined, but > Ada doesn't feel like leaving variables undefined after an assignment. > That's why such a user-defined assignment violates Ada's strong typing. I feel that in certain cases a user-defined assignment can reasonably leave components of the target undefined. Of course, this is in circumstances where the component(s) will never be read, e.g., because other components make it clear that the undefined components are not needed. This sort of thing is probably handled better by variant records, though. Dale