Re: Very confused by Ada tasking, can not explain the execution outcome.
- From: Damien Carbonne <damien.carbonne@xxxxxxx>
- Date: Sat, 30 Aug 2008 12:59:04 +0200
climber.cui@xxxxxxxxx a écrit :
Thank you Jim for modifying the program and making it work. I saw how
you modify the guarding conditions for the procedures. In fact, the
conditions are fine by themselves, because i wrote the same program in
Java. However, the modified program is working now. It indeed reminds
me that Ada probably follows the 'strict evaluation' rule when it
comes to the boolean expressions, so in
if Next=1 and State=0 and D<N and Needs(D) then ...
Ada probably would evaluate all the predicates connect by logical
AND, but as soon as D=N is reached, array index for Needs(_) would go
out of bound (because Needs is defined to be array(0..N-1) of
boolean). I am just guessing here.
Use "and then" instead of "and" to obtain what Java does with "and" :
--> if Next=1 and then State=0 and then D<N and then Needs(D) then ...
.
This would not cause exceptions in Java, because java follows the non-
strict evaluation rule.
tony
- References:
- Very confused by Ada tasking, can not explain the execution outcome.
- From: climber . cui
- Re: Very confused by Ada tasking, can not explain the execution outcome.
- From: climber . cui
- Very confused by Ada tasking, can not explain the execution outcome.
- Prev by Date: Re: Very confused by Ada tasking, can not explain the execution outcome.
- Next by Date: Re: and then... (a curiosity)
- Previous by thread: Re: Very confused by Ada tasking, can not explain the execution outcome.
- Index(es):