On 5/22/06, prad <[EMAIL PROTECTED]> wrote:
this is not openbsd specific, but i wanted to ask people who really understand
the inner workings of programming languages.

suppose that you have 2 conditions A and B where B take a lot of effort to
determine (eg looking for a string match in a huge file).

either A or B needs to be true before you can execute 'this'.

the 2 if statements below are equivalent i think:

if A or B:
        do this

if A:
        do this
elseif B:
        do this

now, do they work the same way?

in the second if A is true we don't need to go looking for B (the more
laborious one).

in the first, do both A and B get evaluated or does A get evaluated first
(because it is first in sequence) and if it is true, no evaluation of B takes
place?

do all programming and shell languages handle this the same way?

--
In friendship,
prad

                                      ... with you on your journey
Towards Freedom
http://www.towardsfreedom.com (website)
Information, Inspiration, Imagination - truly a site for soaring I's



most programming languages take this into account.
if you have

if (condition1 OR condition2 OR ...)
  foo
end if

condition2 is only evaluated/checked if condition1 results in 'false'.
C, Java, Haskell do this, as do most shell languages (actually, all
that i can think of).
It's a pretty standard method for evaluating a disjunction within a conditional.

Hope it helps,
-Ryan

Reply via email to