comp.lang.ada
 help / color / mirror / Atom feed
From: Niklas Holsti <niklas.holsti@tidorum.invalid>
Subject: Re: GNAT 4.4.5 order of conditional processing?
Date: Tue, 15 Nov 2011 21:54:59 +0100
Date: 2011-11-15T21:54:59+01:00	[thread overview]
Message-ID: <9ig1t4F4uaU1@mid.individual.net> (raw)
In-Reply-To: <fedec493-c81e-4bc9-ba94-399028221f77@k26g2000yqd.googlegroups.com>

On 11-11-15 21:30 , awdorrin wrote:
> Given an IF statement such as the following:
>
> if X = Y and not A and B
>
> How does GNAT handle the processing of the conditional statements?
> Will "X = Y" be processed first, and if false, will the rest be
> skipped?

If you want to be sure that the later conjuncts are evaluated only if 
X=Y, use the "and then" form. The following first evaluates "X = Y", and 
then evaluates "not A and B" only if X = Y:

    if X = Y and then (not A and B) then
       do something
    end if;

Or, expand also the later "and" so that B is evaluated only if X = Y and 
A is false:

    if X = Y and then (not A) and then B then
       do something
    end if;

-- 
Niklas Holsti
Tidorum Ltd
niklas holsti tidorum fi
       .      @       .



  reply	other threads:[~2011-11-15 20:55 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-15 20:30 GNAT 4.4.5 order of conditional processing? awdorrin
2011-11-15 20:54 ` Niklas Holsti [this message]
2011-11-15 21:07   ` awdorrin
2011-11-15 21:23     ` Vinzent Hoefler
2011-11-15 21:49       ` awdorrin
2011-11-16 21:31         ` Gautier write-only
2011-11-16 22:40           ` Adam Beneschan
2011-11-17  0:00             ` Adam Beneschan
2011-11-15 23:08 ` Jeffrey Carter
2011-11-16  1:18   ` Adam Beneschan
2011-11-16  5:33     ` tmoran
2011-11-16 17:52       ` awdorrin
2011-11-16 20:01         ` Simon Wright
replies disabled

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