Re: order of clauses

From: "Mitch Vincent" <mitch(at)venux(dot)net>
To: "Steve Wolfe" <steve(at)iboats(dot)com>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: order of clauses
Date: 2001-02-16 21:12:04
Message-ID: 00e901c0985d$1c90b540$0200000a@windows
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Are you referring to short circuit? That's a language feature, isn't it? I
didn't think it had anything to do with the compiler (I know C and a few
other languages do it). Anyway, I could be wrong.. Seems that could break a
lot of code if the programmer relies on short circuit in some conditional
statements.

if ( whatever() OR something() ) {

blah();

}

-- if "whatever" evaluates to true, then "something" isn't executed (the
whole statement is true if one is true)...

This really only comes into play when you're comparing the values returned
by something (a method, function, etc), if you're just looking at boolean
variable I guess it doesn't matter.

-Mitch

----- Original Message -----
From: "Steve Wolfe" <steve(at)iboats(dot)com>
To: <pgsql-general(at)postgresql(dot)org>
Sent: Friday, February 16, 2001 3:10 PM
Subject: Re: order of clauses

> > > will give a divide by zero error as A=(y>0) and B=(x/y>1) can be
> evaluated in
> > > any order (A and B = B and A). I obviously would like (y>0) to happen
> first,
> > > but I don't see how this can be achieved.. Any ideas?
>
> I have one idea that would be nifty to implement. In some compilers,
you
> can turn off complete boolean checking. As soon as any part of an
> expression will invalidate the expression, it stops evaluating all of it.
> That can help you avoid division by zero, and keeps you from evaluating
> parts of the expression that don't matter. It sounds like a good idea, at
> least to an ignoramus like me. : )
>
> steve
>
>
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2001-02-16 21:23:57 Re: Number of Connections
Previous Message Peter Eisentraut 2001-02-16 21:01:09 Re: How to use gethostbyname()