comp.lang.ada
 help / color / mirror / Atom feed
From: dewar@merv.cs.nyu.edu (Robert Dewar)
Subject: Re: Use of constants on EFA
Date: 1997/11/05
Date: 1997-11-05T00:00:00+00:00	[thread overview]
Message-ID: <dewar.878790777@merv> (raw)
In-Reply-To: 63qkmc$8va$1@uttwil.bodensee.com


More on that rule, you quoted the rule as

<<Objects shall be defined as being constant if their value is fixed
throughout the execution of the software.>>

This is definitely stated positively, as a rule for when constant must
be used. It is impossible to derive from the above rule any requirement,
or even implication that "objects shall NOT be defined as being constant
if their value is NOT fixed throughout the execution of the software", to
deduce this from the above statement is simply faulty logic.

You are applying a rule about how to use constant within a scope that
is not derivable from the above rule, but is a reasonable extension of
it.

Actually, how about the following argument that your code does indeed
conform to the rule, and that the rule forces the use of constant in the
cases where you want it.

If you have block:

	declare
	   x : constant String := xxx
        begin
	   ...
        end;

then your customer complains that the value of the object x changes
from one execution of this block to another.

That is wrong, as soon as you leave the block the object x disappears.
When you reenter, a completely new object x is created that has nothing
whatsoever to do with the previous one. 

So multiple executions of this block correspond to multiple objects,
and each of these objects has the quality that its value is fixed from
the point of its creation to the point of its destruction, which is
a reasonable working definition of what is meant by throughout the
execution of the software.

After all consider the global case

  package x is
	y: integer;
        z : constant integer := 3;
	...
  end x;

Is it the case that z has the value from the beginning to the end of the
execution of the program? Certainly not. The object z does not exist until
its declaration is elaborated, i.e. at the point where you elaborate the
declaration of y (or any other packages that are elaborated before package
x), the object z does not exist, and certainly does not contain the value 3.

So in the global case, it is clear that the lifetime that is relevant is
the lifetime of the variable, not the lifetime of the program, and the same
principle applies in identical manner to the multiple objects created by
multiple invocations of a declare block.

Good luck in your fight to prevail here, you are definitely on the right
side of this issue!

Robert Dewar
Ada Core Technologies.





  parent reply	other threads:[~1997-11-05  0:00 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-11-05  0:00 Use of constants on EFA Kevin Wilson
1997-11-05  0:00 ` Robert Dewar
1997-11-05  0:00 ` Robert Dewar [this message]
1997-11-06  0:00   ` Peter Hermann
1997-11-06  0:00 ` Matthew Heaney
     [not found] ` <01bceece$4a6a85e0$423c63c3@default>
1997-11-11  0:00   ` Michael F Brenner
1997-11-12  0:00   ` Karel Th�nissen
1997-11-12  0:00     ` Dale Stanbrough
1997-11-17  0:00       ` KevinWilson
     [not found]       ` <01bcefb3$a8ac9b80$a93163c3@default>
1997-11-17  0:00         ` Richard Toy
  -- strict thread matches above, loose matches on Subject: below --
1997-11-10  0:00 Tom Moran
replies disabled

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