comp.lang.ada
 help / color / mirror / Atom feed
* Use of undefined variables
@ 1988-12-06 16:23 Dale Worley
  0 siblings, 0 replies; only message in thread
From: Dale Worley @ 1988-12-06 16:23 UTC (permalink / raw)



	 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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1988-12-06 16:23 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1988-12-06 16:23 Use of undefined variables Dale Worley

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox