comp.lang.ada
 help / color / mirror / Atom feed
From: Ted Dennison<dennison@telepath.com>
Subject: Re: When to do a constraint check and not ??
Date: Fri, 26 Oct 2001 14:18:38 GMT
Date: 2001-10-26T14:18:38+00:00	[thread overview]
Message-ID: <2heC7.1440$xS6.1918@www.newsranger.com> (raw)
In-Reply-To: 3BD91EF8.EEB7EDBA@systems.saab.se

In article <3BD91EF8.EEB7EDBA@systems.saab.se>, Per Sandberg says...
>
>Assume the folowing code:
>
>procedue bla is
>	b : boolean; --< B may contain any bit pattern at this point.
>
>	procedure test( p : in out boolean ) is
>	begin
>		b := false;
>	end test;
>
>begin
>	test(b); --<< Is the compiler allowed to insert a constraint check on b
>here ??
>end;

I don't see why it wouldn't be allowed to. It seems quite sensible to want to
verify the object before it is read. Reading the variable is what you are saying
will happen in your routine when you give the parameter a mode designator of
"in". 

In this example, there's really no reason why your parameter needs to be "in
out". Even if you had extra code in there that, say, tried to read "b" later on
in "test", you could have used mode "out". The only reason you could possibly
need "in out" is if you might want to read the value inside of "test" *before*
test writes to it. That would clearly only be valid if a valid value is passed
in, and in that case you definitely *want* the constraint check (and probably
want it where they placed it).

---
T.E.D.    homepage   - http://www.telepath.com/dennison/Ted/TED.html

No trees were killed in the sending of this message. 
However a large number of electrons were terribly inconvenienced.



  parent reply	other threads:[~2001-10-26 14:18 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-10-26  8:29 When to do a constraint check and not ?? Per Sandberg
2001-10-26 12:01 ` Peter Hend�n
2001-10-26 13:57 ` DuckE
2001-10-26 14:18 ` Ted Dennison [this message]
2001-10-26 23:44 ` Jeffrey Carter
2001-11-01 17:54 ` Tucker Taft
2001-11-02  3:44   ` Robert Dewar
2001-11-05 10:02 ` Peter Amey
replies disabled

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