[comp.lang.ada] Use of undefined variables

worley@compass.UUCP (Dale Worley) (12/07/88)

	 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