comp.lang.ada
 help / color / mirror / Atom feed
From: Damien Carbonne <damien.carbonne@free.fr>
Subject: Re: Very confused by Ada tasking, can not explain the execution outcome.
Date: Sat, 30 Aug 2008 12:59:04 +0200
Date: 2008-08-30T12:59:04+02:00	[thread overview]
Message-ID: <48b927f8$0$17330$426a74cc@news.free.fr> (raw)
In-Reply-To: <898a5f1d-75f7-4f66-a241-440e9c225454@z66g2000hsc.googlegroups.com>

climber.cui@gmail.com 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



  reply	other threads:[~2008-08-30 10:59 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-30  1:54 Very confused by Ada tasking, can not explain the execution outcome climber.cui
2008-08-30  4:17 ` jimmaureenrogers
2008-08-30  9:34   ` climber.cui
2008-08-30 10:59     ` Damien Carbonne [this message]
2008-08-31 13:37       ` Stephen Leake
2008-08-30  5:12 ` Jeffrey R. Carter
2008-08-30  9:42   ` climber.cui
2008-08-30 13:40     ` Georg Bauhaus
replies disabled

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