comp.lang.ada
 help / color / mirror / Atom feed
From: "Björn Persson" <spam-away@nowhere.nil>
Subject: Re: Order of logical operations
Date: Fri, 04 Jun 2004 21:37:36 GMT
Date: 2004-06-04T21:37:36+00:00	[thread overview]
Message-ID: <AY5wc.94623$dP1.304387@newsc.telia.net> (raw)
In-Reply-To: <Um3wc.43236$3x.40166@attbi_s54>

James Van Buskirk wrote:

> I am curious
> as to how useful short-circuiting logical operators are
> considered to be in languages such as Ada that have both
> short-circuiting and non-short-circuiting operators.

Well I use them frequently in "if" statements where the first test 
determines whether the second test would be valid. An example:

    if Str'Length > 0 and then Str(1) = Apostrophe then
       Do_A;
    else
       Do_B;
    end if;

If Str'Length is zero then there is no Str(1), so without 
short-circuiting operators I'd have to write:

    if Str'Length > 0 then
       if Str(1) = Apostrophe then
          Do_A;
       else
          Do_B;
       end if;
    else
       Do_B;
    end if;

-- 
Björn Persson

jor ers @sv ge.
b n_p son eri nu




  parent reply	other threads:[~2004-06-04 21:37 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <slrncbtfkn.247.tconnors@tellurium.ssi.swin.edu.au>
     [not found] ` <m11xkwd6ct.fsf@macfortran.local>
     [not found]   ` <slrn-0.9.7.4-31741-29330-200406040800-tc@hexane.ssi.swin.edu.au>
     [not found]     ` <40C0208A.80DBE53A@wldelft.nl>
2004-06-04 18:40       ` Order of logical operations James Van Buskirk
2004-06-04 20:06         ` Ed Falis
2004-06-04 21:09           ` Nick Roberts
2004-06-07 17:00             ` Warren W. Gay VE3WWG
2004-06-07 17:36               ` Ed Falis
2004-06-04 21:37         ` Björn Persson [this message]
2004-06-05 10:44         ` Dmitry A. Kazakov
replies disabled

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