From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=0.4 required=5.0 tests=BAYES_00,FORGED_MUA_MOZILLA autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,d0310bb11aeb7260 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.59.229 with SMTP id c5mr29407453pbr.6.1321398518456; Tue, 15 Nov 2011 15:08:38 -0800 (PST) Path: h5ni58972pba.0!nntp.google.com!news1.google.com!news3.google.com!proxad.net!feeder1-2.proxad.net!news-transit.tcx.org.uk!aioe.org!news.tornevall.net!.POSTED!not-for-mail From: Jeffrey Carter Newsgroups: comp.lang.ada Subject: Re: GNAT 4.4.5 order of conditional processing? Date: Tue, 15 Nov 2011 16:08:37 -0700 Organization: TornevallNET - http://news.tornevall.net Message-ID: References: NNTP-Posting-Host: 2d72479df92e4aa0255097910fd7a0aa Mime-Version: 1.0 X-Trace: 9c0ace288695c4247300c2f627db4a91 X-Complaints-To: abuse@tornevall.net User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.23) Gecko/20110922 Thunderbird/3.1.15 X-Complaints-Language: Spoken language is english or swedish - NOT ITALIAN, FRENCH, GERMAN OR ANY OTHER LANGUAGE! In-Reply-To: X-UserIDNumber: 1738 X-Validate-Post: http://news.tornevall.net/validate.php?trace=9c0ace288695c4247300c2f627db4a91 X-Complaints-Italiano: Non abbiamo padronanza della lingua italiana - se mandate una email scrivete solo in Inglese, grazie X-Posting-User: 0243687135df8c4b260dd4a9a93c79bd Xref: news1.google.com comp.lang.ada:18937 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Date: 2011-11-15T16:08:37-07:00 List-Id: On 11/15/2011 01:30 PM, 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? The language specifies that all the conditions must be evaluated. A compiler that does differently isn't Ada. To skip later conditions, use the "short-circuit" forms "and then" and "or else": if P /= null and then P.all = Sentinel then if P = null or else P.all = Sentinel then Note that the short circuit forms should not be considered optimizations. With modern processors, unnecessary short-circuit forms may sometimes be slower than the regular equivalents. -- Jeff Carter "I feel as though somebody stepped on my tongue with muddy feet." Never Give a Sucker an Even Break 112